how to create a header in html
how to create a header in html
1 Answer
Any website on the web starts with the Header so let's create our own header.
We will start with an HTML skeleton:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Qandeel Academy </title>
</head>
<body>
</body>
</html>
Then we will create <div>
and add class
attribute to it, Then put a title using <h1>
tag and subtitle using <h2>
tag inside the <div class="header">
.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Qandeel Academy </title>
</head>
<body>
<div class="header">
<h1>Qandeel Header</h1>
<h2>Our Subtitle goes here!</h2>
</div>
</body>
</html>
Output:
Qandeel Header
Our Subtitle goes here!
Now let's style our header using CSS, we will change the text-align, text size, color, background-color and the padding.
Example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Qandeel Academy </title>
<style>
.header {
padding: 15px;
text-align: center;
background: #f00;
color: white;
font-size: 30px;
}
</style>
</head>
<body>
<div class="header">
<h1>Qandeel Header</h1>
<h2>Our Subtitle goes here!</h2>
</div>
</body>
</html>
Output:
Qandeel Header
Our Subtitle goes here!
answer Link