How to style a header with CSS?

CSSWeb DevelopmentFront End Technology

To style a header using CSS, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      margin: 0;
   }
   .header {
      padding: 30px;
      text-align: center;
      background: #bc1a6b;
      color: white;
      font-size: 30px;
   }
   main {
      padding: 20px;
      font-size: 18px;
   }
</style>
</head>
<body>
<div class="header">
<h1>My website ⇅</h1>
</div>
<main>
<h1>Some heading</h1>
<p>Some sample content.Some sample content.</p>
<p>Some sample content.Some sample content.</p>
<p>Some sample content.Some sample content.</p>
</main>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 12-May-2020 16:16:14
Advertisements