HTML/Training/Style Sheet

From Web Education Community Group
< HTML‎ | Training
Jump to: navigation, search

Style Sheets

Style Sheets can format the HTML document. HTML documents may contain style sheet rules directly in them or they may import style sheets. There are three ways of providing styling information for the Web browsers.

Any style sheet language may be used with HTML. This educational materials use the style language "CSS(Cascading Style Sheets)".

Adding style to HTML

Linking style sheet

You can separate style sheets from HTML documents. Style sheet files are imported to HTML documents by <link>.

This offers several benefits:

  • Authors and Web site managers may share style sheets across a number of documents (and sites).
  • Authors may change the style sheet without requiring modifications to the document.
  • User agents may load style sheets selectively (based on media descriptions).


   <link rel="stylesheet" type="text/css" href="example.css">

See also The link element.

Internal style sheet

You can put style sheet rules in the head of the document by <style>.


     p { color: red; font-size:120%; }
   <p>This is a paragraph</p>

See also The style element.

Inline style sheet

The start tags can contain style sheet rules directly in HTML documents by the style attribute.


 <p style="color: red; font-size:120%; ">This is a paragraph</p>

If you would like to learn CSS syntax, you go to the CSS educational materials for beginners.

In the next content, you will learn the script element.