![]() |
Cascading Style Sheets
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Cascading Style Sheets (CSS) is a standard defined by the World Wide Web Consortium that describes the ways in which the formatting and styling of an HTML page can be influenced. For full information on this topic you should view the W3C CSS site. Usefully most modern browsers support this standard to one degree or another, with more and more support being built in with each new version. The standard has been designed in such a way that it will replace some HTML tags altogether, and augment others. Stylesheet DefinitionStylesheets can be defined for use within the HTML in several ways. Each method has its benefits and its drawbacks.
Rule SyntaxAll CSS rules follow the same syntax and have 3 basic parts: a selector, a property and a property value.
Rule selectors define which HTML tags are affected by the associated properties. The rule properties control the tag display attributes that you wish to change, each of which take a value as shown below.
Selectors can be grouped together so that the rule properties apply to all the HTML tags matched by the group. Grouped selectors are separated by a comma.
SelectorsThe browser is informed of what to do when rendering HTML tags by matching the tags against rules in the stylesheets that are in force for the page. There are various ways rule selectors are matched against tags, the most commonly used ones being:
Rule PropertiesThere are a large number of style properties defined in the CSS standard plus more non-standard ones that individual browser manufacturers have made available. Properties can be grouped together into categories that control particular aspects of the rendition of an HTML tag.
Properties from any of the categories can be combined together in the same rule to create the final style. However, for the values of the specified properties to be effective the properties must be pertinent to the tag matching the rule selector. CascadingWhen many rules match a particular HTML tag the properties from each rule are collected together to form the final set that is applied. Properties mentioned in rules encountered last override any existing property of the same name in earlier rules. Also if a property is set in a rule that matches a container tag, such as <BODY> or <DIV> all the contained tags inherit that property value unless specifically changed in a more closely matching rule. Together these behaviours are known as cascading, that is, property values cascade down through stylesheets, selectors and rules to the individual HTML tags. It is possible for tags intended to be styled by a class selector rule to match more than one classrule at a time. To do this specify a list of class names separated by a space as the value of the HTML tag class attribute. The properties contained by the matched rules are cascaded together to form the final set applied to the tag. |
|
Content of this page Copyright © Robert Quince 1996 - 2005. |