Thursday 8 March 2012

Cascading Style Sheets

Cascading Appearance Sheets (CSS) is a appearance area accent acclimated for anecdotic the presentation semantics (the attending and formatting) of a certificate accounting in a markup language. Its best accepted appliance is to appearance web pages accounting in HTML and XHTML, but the accent can additionally be activated to any affectionate of XML document, including apparent XML, SVG and XUL.

CSS is advised primarily to accredit the break of certificate agreeable (written in HTML or a agnate markup language) from certificate presentation, including elements such as the layout, colors, and fonts.1 This break can advance agreeable accessibility, accommodate added adaptability and ascendancy in the blueprint of presentation characteristics, accredit assorted pages to allotment formatting, and abate complication and alliteration in the structural agreeable (such as by acceptance for tableless web design). CSS can additionally acquiesce the aforementioned markup folio to be presented in altered styles for altered apprehension methods, such as on-screen, in print, by articulation (when apprehend out by a speech-based browser or awning reader) and on Braille-based, concrete devices. It can additionally be acclimated to acquiesce the web folio to affectation abnormally depending on the awning admeasurement or accessory on which it is actuality viewed. While the columnist of a certificate about links that certificate to a CSS appearance sheet, readers can use a altered appearance sheet, conceivably one on their own computer, to override the one the columnist has specified.

CSS specifies a antecedence arrangement to actuate which appearance rules administer if added than one aphorism matches adjoin a accurate element. In this alleged cascade, priorities or weights are affected and assigned to rules, so that the after-effects are predictable.

The CSS blueprint are maintained by the World Wide Web Consortium (W3C). Internet media blazon (MIME type) text/css is registered for use with CSS by RFC 2318 (March 1998).

Syntax

CSS has a simple syntax and uses a cardinal of English keywords to specify the names of assorted appearance properties.

A appearance area consists of a account of rules. Anniversary aphorism or rule-set consists of one or added selectors and a acknowledgment block. A declaration-block consists of a account of declarations in braces. Anniversary acknowledgment itself consists of a property, a colon (:), and a value. If there are assorted declarations in a block, a semi-colon (;) charge be amid to abstracted anniversary declaration.2

In CSS, selectors are acclimated to acknowledge which of the markup elements a appearance applies to, a affectionate of bout expression. Selectors may administer to all elements of a specific type, or alone those elements that bout a assertive attribute; elements may be akin depending on how they are placed about to anniversary added in the markup code, or on how they are nested aural the Document Object Model.

Pseudo-classes are addition anatomy of blueprint acclimated in CSS to analyze markup elements, and in some cases, specific user accomplishments to which a accurate acknowledgment block applies. An often-used archetype of a pseudo-class is :hover, which applies a appearance alone back the user 'points to' the arresting element, usually by captivation the abrasion cursor over it. It is added to a selector as in a:hover or #elementid:hover. Added pseudo-classes and pseudo-elements are, for example, :first-line, :visited or :before. A appropriate pseudo-class is :lang(c), "c".clarification needed

A pseudo-class selects absolute elements, such as :link or :visited, admitting a pseudo-element makes a alternative that may abide of fractional elements, such as :first-line or :first-letter.

Selectors may be accumulated in added means too, abnormally in CSS 2.1, to accomplish greater specificity and flexibility.3

Here is an archetype accretion up the rules above:

Use

Prior to CSS, about all of the adumbrative attributes of HTML abstracts were independent aural the HTML markup; all chantry colors, accomplishments styles, aspect alignments, borders and sizes had to be absolutely described, about repeatedly, aural the HTML. CSS allows authors to move abundant of that advice to addition file, alleged a appearance sheet, consistent in appreciably simpler HTML.

Headings (h1 elements), sub-headings (h2), sub-sub-headings (h3), etc., are authentic structurally application HTML. In book and on the screen, best of font, size, blush and accent for these elements is presentational.

Prior to CSS, certificate authors who capital to accredit such typographic characteristics to, say, all h2 headings had to use the HTML chantry and added adumbrative elements for anniversary accident of that branch type. The added adumbrative markup in the HTML fabricated abstracts added complex, and about added difficult to maintain. In CSS, presentation is afar from structure. In print, CSS can ascertain color, font, argument alignment, size, borders, spacing, blueprint and abounding added typographic characteristics. It can do so apart for on-screen and printed views. CSS additionally defines non-visual styles such as the acceleration and accent with which argument is apprehend out by aural argument readers. The W3C now considers the advantages of CSS for defining all aspects of the presentation of HTML pages to be above to added methods. It has accordingly deprecated the use of all the aboriginal adumbrative HTML markup.

CSS files are amid into HTML abstracts application the afterward syntax:

Difficulty with adoption

The CSS 1 blueprint was completed in 1996. Microsoft's Internet Explorer 39 was appear in that year, featuring some bound abutment for CSS. But it was added than three years afore any web browser accomplished near-full accomplishing of the specification. Internet Explorer 5.0 for the Macintosh, alien in March 2000, was the aboriginal browser to accept abounding (better than 99 percent) CSS 1 support,11 before Opera, which had been the baton aback its addition of CSS abutment 15 months earlier. Added browsers followed anon afterwards, and abounding of them additionally implemented genitalia of CSS 2. As of August 2010, no (finished) browser has absolutely implemented CSS 2, with accomplishing levels capricious (see Comparison of blueprint engines (CSS)).

Even admitting aboriginal browsers such as Internet Explorer 39 and 4, and Netscape 4.x had abutment for CSS, it was about abridged and had austere bugs. This was a austere obstacle for the acceptance of CSS.

When after 'version 5' browsers began to action a adequately abounding accomplishing of CSS, they were still incorrect in assertive areas and were abounding with inconsistencies, bugs and added quirks. The admeasurement of such CSS-related inconsistencies and alike the aberration in affection abutment has fabricated it difficult for designers to accomplish a constant actualization beyond browsers and platforms. Some authors resorted to workarounds such as CSS hacks and CSS filters.

Problems with browsers' patchy acceptance of CSS, forth with errata in the aboriginal specification, led the W3C to alter the CSS 2 accepted into CSS 2.1, which confused nearer to a alive snapshot of accepted CSS abutment in HTML browsers. Some CSS 2 backdrop that no browser auspiciously implemented were dropped, and in a few cases, authentic behaviors were afflicted to accompany the accepted into band with the absolute absolute implementations. CSS 2.1 became a Candidate Recommendation on February 25, 2004, but CSS 2.1 was pulled aback to Alive Draft cachet on June 13, 2005,12 and alone alternate to Candidate Recommendation cachet on July 19, 2007.13

In the past, some web servers were configured to serve all abstracts with the filename addendum .css14 as mime blazon application/x-pointplus15 rather than text/css. At the time, the Net-Scene aggregation was affairs PointPlus Maker to catechumen PowerPoint files into Compact Slide Show files (using a .css extension).16

CSS1

The aboriginal CSS blueprint to become an official W3C Recommendation is CSS akin 1, appear in December 1996.17 Among its capabilities are abutment for

Font backdrop such as book and emphasis

Color of text, backgrounds, and added elements

Argument attributes such as agreement amid words, letters, and curve of text

Alignment of text, images, tables and added elements

Margin, border, padding, and accession for best elements

Unique identification and all-encompassing allocation of groups of attributes

The W3C no best maintains the CSS1 Recommendation.18

CSS 2.1

CSS akin 2 afterlight 1, generally referred to as "CSS 2.1", fixes errors in CSS2, removes poorly-supported or not absolutely interoperable appearance and adds already-implemented browser extensions to the specification. In adjustment to accede with the W3C Process for standardizing abstruse specifications, CSS 2.1 went aback and alternating amid Working Draft cachet and Candidate Recommendation cachet for abounding years. CSS 2.1 aboriginal became a Candidate Recommendation on February 25, 2004, but it was changed to a Working Draft on June 13, 2005 for added review. It alternate to Candidate Recommendation on 19 July 2007 and afresh adapted alert in 2009. However, aback changes and clarifications were made, it afresh went aback to Last Call Working Draft on 7 December 2010.

CSS 2.1 went to Proposed Recommendation on 12 April 2011.20 After actuality advised by the W3C Advisory Committee, it was assuredly appear as a W3C Recommendation on 7 June 2011.21

CSS3

Unlike CSS2, which is a ample distinct blueprint defining assorted features, CSS3 is disconnected into several abstracted abstracts alleged "modules". Each bore adds fresh capabilities or extends appearance authentic in CSS2, over attention astern compatibility. Work on CSS akin 3 started about the time of advertisement of the aboriginal CSS2 recommendation. The ancient CSS3 drafts were appear in June 1999.22

Due to the modularization, altered modules accept altered adherence and statuses.23 As of November 2011, there are over fifty CSS modules appear from the CSS Working Group.22 Three of them―Selectors, Namespaces and Color― became W3C Advocacy in 2011.

Some modules, such as Backgrounds and Colors, Media Queries, and Multi-column Layout, accept a Candidate Advocacy cachet and are brash moderately stable. At this stage, implementations are brash to bead bell-ringer prefixes.24