Cascading Stylesheets (CSS) have been designed as a language for better separating presentation-specific issues from the structuring of documents as provided by HTML. However, CSS can be applied to XML as well, either directly (by applying a CSS stylesheet to an XML document), or as an supplement to basic HTML layout structures generated from an XML document. CSS uses a simple model of selectors and declarations. Selectors specify to which elements of a document a set of declarations (each being a value assigned to a property) apply; in addition there is a model of how property values are inherited and cascaded. The biggest limitation of CSS is that it cannot change the structure of the displayed document.
pollutedby layout information
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Naked HTML</title> </head> <body> <p>some text in a paragraph..</p> <ol> <li>an ordered list's first item</li> <li>and the second one</li> </ol> <table> <tr><td>row 1, column 1</td><td>row 2, second column</td></tr> <tr><td>another row, first column</td><td>the last table cell</td></tr> </table> </body> </html>
<peter> <paul> <mary>Naked HTML</mary> </paul> <bob> <bill>some text in a paragraph..</bill> <george> <hillary>an ordered list's first item</hillary> <hillary>and the second one</hillary> </george> <jim> <joe><jill>row 1, column 1</jill><jill>row 2, second column</jill></joe> <joe><jill>another row, first column</jill><jill>the last table cell</jill></joe> </jim> </bob> </peter>
peter { margin : 10px ; } paul { display : none ; } bill { display : block ; } george { counter-reset : hillary ; margin : 5px ; } hillary { display: block ; } hillary:before { content : counter(hillary) ". " ; counter-increment : hillary ; } jim { display : table ; } joe { display : table-row ; } jill { display : table-cell ; }
<head> <title>CSS Usage</title> <link rel="stylesheet" href="http://dret.net/dretnet.css" type="text/css"/> <style type="text/css"> li { color : red } </style> </head> <body> <p>some text in a paragraph..</p> <ol> <li>an ordered list's first item</li> <li style=" text-decoration : underline ">and the second one</li> </ol>
CSS namespace
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="naked.css" type="text/css"?> <peter> <paul> <mary>Naked HTML</mary>
peter { margin : 10px ; } paul { display : none ; }
deprecated
quotes: q:before { content : open-quote }
table { display: table } tr { display: table-row } thead { display: table-header-group } tbody { display: table-row-group } tfoot { display: table-footer-group } col { display: table-column } colgroup { display: table-column-group } td, th { display: table-cell } caption { display: table-caption }
Automatic | Fixed | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Multicolumn Layout in HTML</title> <style type="text/css"> .multicol { -moz-column-count : 4 ; -moz-column-gap: 3% ; } h2 { -moz-column-break-before: always ; -moz-column-break-after: avoid ; } h3 { -moz-column-break-after: avoid ; } </style> </head> <body> <h1>Multicolumn Layout in HTML</h1> <div class="multicol"> <h2>Multicol Title</h2>