By using this site you agree to the use of cookies and related technologies.

Learn more

Style - HTML Element

The style element of HTML is used to add styling rules, either embedded or external.

Edited: 2016-10-04 14:12

The HTML style Element is used to embed styling rules directly in a page, or load external styling rules, (such as CSS StyleSheet). The rules contained in a style element are used to control the appearance and layout of a page.

External StyleSheets are normally added with the link element in the head of a page, but can also be added using a @import rule. I.e.:

 <style type="text/css">
   @import url("/style.css");
 </style>

Attributes

Attribute:Value:Description:
AttributesOther AttributesGlobal, I18n, Event
typeContent TypeThe Content Type of the scripting language used.
mediaMedia DescriptorEither a single, or comma-separated list. I.e. "screen,print"
titleTextAdvisory title

Example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

  <head>
    <title>My first Website</title>
    <style type="text/css">
      h1 {color:#0000FF;}
      p {font-size:2em;}
    </style>
  </head>

  <body>
    <h1>My first use of Style</h1>
    <p>Using CSS to change the style of headings and paragraphs</p>

  </body>

</html>