How to add CSS rules into an HTML document

JavascriptWeb DevelopmentFront End Scripts

You can put your CSS rules into an HTML document using the <style> element. This tag is placed inside <head>...</head> tags. Rules defined using this syntax will be applied to all the elements available in the document.

The following is an example:

<!DOCTYPE html>
<html>
   <head>
      <style media = "all">
         body {
            background-color: linen;
         }
         h1 {
            color: maroon;
            margin-left: 40px;
         }
      </style>
   </head>
   <body>
      <h1>This is a heading</h1>
      <p>This is a paragraph.</p>
   </body>
</html>
raja
Published on 13-Apr-2018 07:47:17
Advertisements