Using Inline Styles in XHTML

In XHTML, you can also create inline styles, in which you apply styles to one XHTML element only. You create inline styles with the style attribute that most XHTML elements have. Here's an example. This example creates the same result as the previous two examples, but this time I'm using the style attribute, not the <link> element to link to an external stylesheet or the <style> element to create an embedded stylesheet:

Listing ch17_11.html
 <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">     <head>         <title>             Working With External Style Sheets         </title>     </head>  <body style="background-color: #FFFFCC; font-family: Arial">  <center>            <h1>                Working With External Style Sheets            </h1>  <p style="font-style: italic">  This document is displayed using an external style sheet.            </p>        </center>     </body> </html> 

You usually use inline styles for short amounts of text; in fact, style purists insist that you should stay away from inline styles because this decentralizes the definition of styles, mixing markup with content more than they like. Note that, as with embedded stylesheets, if your stylesheet includes the characters < , or & , or ]]> , or -- , you should make your stylesheet external.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net