How to Linking CSS to a Web Document


We can use any of three methods to specify CSS styling rules for elements in an HTML document, but only one method to specify CSS rules for XML documents. We can use all four methods with XHTML documents that are served as XML. XHTML served as HTML is HTML as far as browsers are concerned, so only the three HTML methods can be used in that case. See Differences Between HTML and XHTML (p. 409) for details about the different ways in which you can serve XHTML.
The methods are:
  • Place the rules in a separate, external style sheet that’s referenced by a link element or an @import rule in a style element (HTML, XHTML).
  • Place the rules within an separate, internal style sheet within a style element (HTML, XHTML).
  • Place the rules in inline CSS specified in a style attribute of a markup tag (HTML, XHTML).
  • Place the rules in a separate, external style sheet referenced by a processing instruction (or PI) (XML).
Separate style sheets—both external and internal—can be targeted to one or more output media. External style sheets can be specified as alternative, which means that they’re not applied by default, but can be enabled by users in browsers that support alternative style sheets.

How to Linking CSS to a Web Document How to Linking CSS to a Web Document Reviewed by JohnBlogger on 3:09 AM Rating: 5

No comments: