![]() |
Cascading Style Sheets CSS 2CSS Style Sheet Classes & Comments |
|
|
CSS Style Sheet Classes Classes can be used to further define styles for different occurrences and uses of particular selectors by using the CLASS attribute with the corresponding tags. If the following rules are defined for the style sheet: H1.title {color: red} within the HTML document you can invoke different styles for different circumstances by using the CLASS attribute. The HTML would be: <H1 CLASS=title>Home Page</H1> If you omit the selector from the definition, the class definition can be used with a range of tags, as a generic value. For example, if we defined the following class in the style sheet as: .detail {color: green} it can be used in the HTML code as: <P CLASS=detail> Assigning a Style To a Particular Element A style can be assigned to a particular element by giving it an ID code, and then using that ID within the HTML tag. For example, if we declare an ID code to represent a color: #loud {color: red} <P ID=loud>This text is emphasised</P> Comments in CSS Style Sheets Comments can be added to style sheets using the /* and */ symbols. For example: H1 {color: red} /* Emphasises the heading */ These symbols can also be used to insert block comments: /*-------------------------------------------------------------------------------- |
| © & Design by systemalchemy.com |