Pages

CSS Rules

Monday, 5 November 2012



CSS rules are made up of a selector and at least one declaration. A selector is the code that selects the HTML to which you want to apply the style rule. A declaration is made up of at least one CSS property and related property value. CSS properties define the style:
h1 {color: red;}
Six types of style sheets exist:
  • Browser style This is the default style sheet within a browser. If you declare no style rules, these defaults are applied.
  • User style A user can write a style sheet and make it override any styles you create by changing a setting in the browser.
  • Inline style This is style that is used right in the individual element and applied via the style attribute.
  • Embedded style This is style that controls one document and is placed inside the style element within the HTML document.
  • Linked style This is a style sheet that is linked to an HTML document using the link element in the head of the document.
  • Imported style This is similar to linked styles, but it enables you to import styles into a linked style sheet as well as directly into a document.

Inheritance

Inheritance means that styles are inherited from their parent elements. Consider the following:
<body>
<h1>My header</h1>
<p>Subsequent Text</p>
</body>
Both the h1 and p elements are considered children of the body element. The styles you give to the body will be inherited by the children until you make another rule that overrides the inherited style.

No comments:

Post a Comment

 

Labels

Blogger news

Blogroll

Most Reading

Tags