Difference between revisions of "Cascading Style Sheets"
(→External links (resources)) |
|||
Line 1: | Line 1: | ||
− | In computing, '''Cascading Style Sheets''' ('''CSS''') is a | + | In computing, '''Cascading Style Sheets''' ('''CSS''') is a stylesheet language used to describe the presentation of a document written in a markup language. Its most common application is to style web pages written in [[HTML]] and [[XHTML]], but the language can be applied to any kind of [[XML]] document, including [[Scalable Vector Graphics|SVG]] and XUL. The CSS specifications are maintained by the World Wide Web Consortium (W3C). |
==Overview== | ==Overview== | ||
− | CSS is used by both the authors and readers of | + | CSS is used by both the authors and readers of web pages to define colours, fonts, layout, and other '''aspects''' of document presentation. It is designed primarily to enable the separation of document structure (written in HTML or a similar markup language) from document presentation (written in CSS). This separation can improve content accessibility, provide more flexibility and control in the specification of presentational characteristics, and reduce complexity and repetition in the structural content. CSS can also allow the same markup page to be presented in different styles for different rendering methods, such as on-screen, in print, by voice (when read out by a speech-based browser or screen reader) and on braille-based, tactile devices. Similarly, identical HTML or XML markup can be displayed in different 'brands', liveries or colour schemes on different but related web sites referencing different CSS. |
==Recommendations== | ==Recommendations== | ||
− | The first CSS specification to become an official W3C Recommendation is CSS level 1, published in December | + | The first CSS specification to become an official W3C Recommendation is CSS level 1, published in December 1996. Among its capabilities are support for: |
− | * | + | * Font properties such as typeface and emphasis |
− | * | + | * Colour of text, backgrounds, and other elements |
* Text attributes such as spacing between words, letters, and lines of text | * Text attributes such as spacing between words, letters, and lines of text | ||
− | * | + | * Alignment of text, images, tables and other elements |
− | * | + | * Margin, border, padding, and positioning for most elements |
* Unique identification and generic classification of groups of attributes | * Unique identification and generic classification of groups of attributes | ||
The W3C maintains the [http://www.w3.org/TR/REC-CSS1 CSS1 Recommendation]. | The W3C maintains the [http://www.w3.org/TR/REC-CSS1 CSS1 Recommendation]. | ||
− | CSS level 2 was developed by the W3C and published as a Recommendation in May | + | CSS level 2 was developed by the W3C and published as a Recommendation in May 1998. A superset of CSS1, CSS2 includes a number of new capabilities, among them the absolute, relative, and fixed positioning of elements, the concept of media types, support for aural style sheets and bidirectional text, and new font properties such as shadows. The W3C maintains the [http://www.w3.org/TR/REC-CSS2/ CSS2 Recommendation]. |
− | CSS level 2 revision 1 or CSS 2.1 fixes errors in CSS2, removes poorly-supported features and adds already-implemented browser extensions to the specification. While it was a [http://www.w3.org/TR/CSS21/ Candidate Recommendation] for several months, on | + | CSS level 2 revision 1 or CSS 2.1 fixes errors in CSS2, removes poorly-supported features and adds already-implemented browser extensions to the specification. While it was a [http://www.w3.org/TR/CSS21/ Candidate Recommendation] for several months, on 15 June 2005 it was reverted to a working draft for further review. |
− | CSS level 3 is currently under | + | CSS level 3 is currently under development. The W3C maintains a [http://www.w3.org/Style/CSS/current-work#table CSS3 progress report]. |
==CSS experiments== | ==CSS experiments== | ||
Line 33: | Line 33: | ||
These experiments are usually only compatible with browsers that are largely standards compliant. | These experiments are usually only compatible with browsers that are largely standards compliant. | ||
+ | |||
+ | ==Rarely used CSS properties== | ||
+ | ''Note: See "[http://www.seomoz.org/blog/css-properties-you-probably-never-use 15 CSS Properties You Probably Never Use (but perhaps should)]" — by Matthew Inman (Oatmeal); 2007-02-15''. | ||
+ | |||
+ | * clip | ||
+ | clip: rect(5px, 40px, 45px, 5px) | ||
+ | * visibility | ||
+ | visibility: (inherit | visible | hidden) | ||
+ | * text-shadow | ||
+ | text-shadow: color, x-coordinate, y-coordinate, blur radius | ||
+ | text-shadow: #000000 10px -5px 1px | ||
+ | * content | ||
+ | content: "Your browser supports content" | ||
+ | * quotes (note: [http://alistapart.com/ A List Apart] endorses the revival of the <q> tag using content) | ||
+ | q { quotes: '"' '"' } | ||
+ | * counter-reset and counter-increment | ||
+ | body { | ||
+ | counter-reset: section; /* Set the section counter to 0 */ | ||
+ | } | ||
+ | h1:before { | ||
+ | counter-increment: section; /* Increment the section counter */ | ||
+ | content: "Section " counter(section) ": "; /* Display the counter */ | ||
+ | } | ||
+ | * marks | ||
+ | @page: { marks: <value>; } | ||
+ | * page-break-before and page-break-after | ||
+ | page-break-before: (always|auto|empty string|left|right); | ||
+ | page-break-after: (always|auto|empty string|left|right); | ||
+ | * orphans and widows | ||
+ | orphans: <integer> | ||
+ | widows: <integer> | ||
+ | * font-size-adjust | ||
+ | font-size-adjust: number | ||
+ | * font-stretch | ||
+ | font-stretch: (normal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit) | ||
+ | |||
+ | :From the W3C: The 'font-stretch' property selects a normal, condensed, or extended face from a font family. Absolute keyword values have the following ordering, from narrowest to widest: | ||
+ | :# ultra-condensed | ||
+ | :# extra-condensed | ||
+ | :# condensed | ||
+ | :# semi-condensed | ||
+ | :# normal | ||
+ | :# semi-expanded | ||
+ | :# expanded | ||
+ | :# extra-expanded | ||
+ | :# ultra-expanded | ||
+ | |||
+ | * font-variant | ||
+ | font-variant: (normal | small-caps) | ||
+ | |||
+ | * caption-side | ||
+ | caption-side: (top | bottom | left | right) | ||
+ | |||
+ | * table-layout | ||
+ | table-layout: (auto | fixed) | ||
+ | |||
+ | * empty-cells | ||
+ | empty-cells: (show | hide) | ||
==References== | ==References== | ||
− | * W3C: ''[http://www.w3.org/Style/CSS/ | + | * W3C: ''[http://www.w3.org/Style/CSS/ Cascading Style Sheets, home page] CSS Home Page'' |
* W3C: ''[http://www.w3.org/TR/CSS1 Cascading Style Sheets, level 1] CSS 1 specification'' | * W3C: ''[http://www.w3.org/TR/CSS1 Cascading Style Sheets, level 1] CSS 1 specification'' | ||
* W3C: ''[http://www.w3.org/TR/CSS21 Cascading Style Sheets, level 2 revision 1] CSS 2.1 specification'' | * W3C: ''[http://www.w3.org/TR/CSS21 Cascading Style Sheets, level 2 revision 1] CSS 2.1 specification'' | ||
Line 49: | Line 107: | ||
==CSS books== | ==CSS books== | ||
* Wikibooks | * Wikibooks | ||
− | * | + | * Jeffrey Zeldman: ''Designing With Web Standards'', New Riders, ISBN 0735712018 (paperback) ([http://www.zeldman.com/dwws/ book's companion site]) |
− | * | + | * Eric A. Meyer: ''Cascading Style Sheets: The Definitive Guide'', 2nd Edition, O'Reilly & Associates, ISBN 0596005253 |
− | * | + | * Eric A. Meyer: ''Cascading Style Sheets 2.0 Programmer's Reference'', McGraw-Hill Osborne Media, ISBN 0072131780 |
− | * | + | * Keith Schengili-Roberts: ''Core CSS, 2nd Edition'', Prentice Hall, ISBN 0-130-09278-9 |
* [http://www.aw-bc.com/catalog/academic/product/0,1144,0321193121,00.html ''Cascading Style Sheets: Designing for the Web''] by Håkon Wium Lie and Bert Bos | * [http://www.aw-bc.com/catalog/academic/product/0,1144,0321193121,00.html ''Cascading Style Sheets: Designing for the Web''] by Håkon Wium Lie and Bert Bos | ||
* ''The Zen of CSS Design'' (co-authored by CSS Zen Garden Owner, Dave Shea), ISBN 0321303474 | * ''The Zen of CSS Design'' (co-authored by CSS Zen Garden Owner, Dave Shea), ISBN 0321303474 |
Revision as of 07:38, 16 February 2007
In computing, Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can be applied to any kind of XML document, including SVG and XUL. The CSS specifications are maintained by the World Wide Web Consortium (W3C).
Contents
Overview
CSS is used by both the authors and readers of web pages to define colours, fonts, layout, and other aspects of document presentation. It is designed primarily to enable the separation of document structure (written in HTML or a similar markup language) from document presentation (written in CSS). This separation can improve content accessibility, provide more flexibility and control in the specification of presentational characteristics, and reduce complexity and repetition in the structural content. CSS can also allow the same markup page to be presented in different styles for different rendering methods, such as on-screen, in print, by voice (when read out by a speech-based browser or screen reader) and on braille-based, tactile devices. Similarly, identical HTML or XML markup can be displayed in different 'brands', liveries or colour schemes on different but related web sites referencing different CSS.
Recommendations
The first CSS specification to become an official W3C Recommendation is CSS level 1, published in December 1996. Among its capabilities are support for:
- Font properties such as typeface and emphasis
- Colour of text, backgrounds, and other elements
- Text attributes such as spacing between words, letters, and lines of text
- Alignment of text, images, tables and other elements
- Margin, border, padding, and positioning for most elements
- Unique identification and generic classification of groups of attributes
The W3C maintains the CSS1 Recommendation.
CSS level 2 was developed by the W3C and published as a Recommendation in May 1998. A superset of CSS1, CSS2 includes a number of new capabilities, among them the absolute, relative, and fixed positioning of elements, the concept of media types, support for aural style sheets and bidirectional text, and new font properties such as shadows. The W3C maintains the CSS2 Recommendation.
CSS level 2 revision 1 or CSS 2.1 fixes errors in CSS2, removes poorly-supported features and adds already-implemented browser extensions to the specification. While it was a Candidate Recommendation for several months, on 15 June 2005 it was reverted to a working draft for further review.
CSS level 3 is currently under development. The W3C maintains a CSS3 progress report.
CSS experiments
Recently, there has been a trend among web designers to document all their experiments with CSS on a section of their site. Examples include:
- css/edge
- Newt Edge
- CSS Play
- CSS Experiments
- Virtuelvis Gallery
- Position is Everything
- the CSS playground
These experiments are usually only compatible with browsers that are largely standards compliant.
Rarely used CSS properties
Note: See "15 CSS Properties You Probably Never Use (but perhaps should)" — by Matthew Inman (Oatmeal); 2007-02-15.
- clip
clip: rect(5px, 40px, 45px, 5px)
- visibility
visibility: (inherit | visible | hidden)
- text-shadow
text-shadow: color, x-coordinate, y-coordinate, blur radius text-shadow: #000000 10px -5px 1px
- content
content: "Your browser supports content"
- quotes (note: A List Apart endorses the revival of the
tag using content)
q { quotes: '"' '"' }
- counter-reset and counter-increment
body { counter-reset: section; /* Set the section counter to 0 */ } h1:before { counter-increment: section; /* Increment the section counter */ content: "Section " counter(section) ": "; /* Display the counter */ }
- marks
@page: { marks: <value>; }
- page-break-before and page-break-after
page-break-before: (always|auto|empty string|left|right); page-break-after: (always|auto|empty string|left|right);
- orphans and widows
orphans: <integer> widows: <integer>
- font-size-adjust
font-size-adjust: number
- font-stretch
font-stretch: (normal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit)
- From the W3C: The 'font-stretch' property selects a normal, condensed, or extended face from a font family. Absolute keyword values have the following ordering, from narrowest to widest:
- ultra-condensed
- extra-condensed
- condensed
- semi-condensed
- normal
- semi-expanded
- expanded
- extra-expanded
- ultra-expanded
- font-variant
font-variant: (normal | small-caps)
- caption-side
caption-side: (top | bottom | left | right)
- table-layout
table-layout: (auto | fixed)
- empty-cells
empty-cells: (show | hide)
References
- W3C: Cascading Style Sheets, home page CSS Home Page
- W3C: Cascading Style Sheets, level 1 CSS 1 specification
- W3C: Cascading Style Sheets, level 2 revision 1 CSS 2.1 specification
- W3C: CSS: under construction, CSS 3, etc.
See also
- W3C
- List of stylesheet languages
- Comparison of layout engines (CSS)
- CSS Zen Garden
- CSS Property Index
CSS books
- Wikibooks
- Jeffrey Zeldman: Designing With Web Standards, New Riders, ISBN 0735712018 (paperback) (book's companion site)
- Eric A. Meyer: Cascading Style Sheets: The Definitive Guide, 2nd Edition, O'Reilly & Associates, ISBN 0596005253
- Eric A. Meyer: Cascading Style Sheets 2.0 Programmer's Reference, McGraw-Hill Osborne Media, ISBN 0072131780
- Keith Schengili-Roberts: Core CSS, 2nd Edition, Prentice Hall, ISBN 0-130-09278-9
- Cascading Style Sheets: Designing for the Web by Håkon Wium Lie and Bert Bos
- The Zen of CSS Design (co-authored by CSS Zen Garden Owner, Dave Shea), ISBN 0321303474
- Cascading Style Sheets: The Definitive Guide
- Eric Meyer On CSS
- More Eric Meyer On CSS
CSS discussions
External links
Tutorials
- Style Sheets Tutorials - Step by step lessons.
- Style Master CSS Tutorial - A good introductory tutorial.
Demonstrations
- CSS Zen Garden - Showcases the powerful abilities of CSS.
- CSS Beauty - CSS Design Showcase.
- Stylegala - Web Design Publication.
Resources
Validation
- The W3C CSS Validation Service - Verify the syntax of all or part of a stylesheet.
Reference
- CSS crib sheet - A quick reference "cheat" sheet.
- CSS Cheat Sheet - A printable single-page quick reference for CSS.
- CSS News - Repository of latest tips and tricks in the world of CSS Design.
Browser issues
- Position Is Everything - Articles on CSS bugs in different browsers and workarounds to common CSS problems
- CSS1 Acid test
- CSS2 Acid2 test and its announcement
About the box model
- CSS Box Model - A guide to the box model in CSS and how different browsers treat it.
- Interactive CSS Box Model Demo
External links (resources)
- CSS layout examples
- Using Fewer Images
- LogoPond
- CSS Globe — Web standards news
- List of CSS Tools