Computer >> Computer tutorials >  >> Programming >> Javascript

Example of embedded CSS


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

Following is the example of embed CSS based on the above syntax:

<!DOCTYPE html>
<html>
   <head>
      <style media = "all">
         body {
            background-color: orange;
         }
         h1 {
            color: yellow;
            margin-left: 30px;
         }
      </style>
   </head>
   <body>
      <h1>This is a heading</h1>
      <p>This is a paragraph.</p>
   </body>
</html>

The following is the attribute:

AttributeValueDescription
Typetext/cssSpecifies the style sheet language as a content-type (MIME type). This is required attribute.
mediascreen
tty
tv
projection
handheld
print
braille
aural
all
Specifies the device the document will be displayed on. The default value is all. This is an optional attribute.