Cascading Style Sheets: Alexander Zangerl Az@bond - Edu.au
Cascading Style Sheets: Alexander Zangerl Az@bond - Edu.au
1 / 21
introduction
http://www.w3.org/MarkUp/Guide/Style
W3C created STYLES in addition to HTML 4.0 dene HOW to display elements document may use one, two or more style sheets applied according to specied priorities (= cascade) can be specied inside a single HTML element (inline) inside the <head> element of an HTML page (embedded) or in an external CSS le (linked) can be mixed
2 / 21
has features
Associating CSS to Documents [feature] CSS Cascading [feature] CSS Media [feature] CSS Grouping [feature] CSS Inheritance [feature] CSS pseudo elements [feature] CSS positioning and sizing [feature]
instances
CSS3 CSS2 CSS1
Cascading Style Sheets 3 / 21
CSS document
can be written in any text editor has .css extension consists of
CSS Rule
4 / 21
CSS Cascading
multiple sheets can be applied to a document (browser, reader, server, author) conict resolution at clashes denes what style will be used: browser default -> External Style Sheet -> Internal Style Sheet -> Inline Style observation
inline style has the highest priority
5 / 21
Inline CSS
these modify the behaviour of a single tag, a group of tags, or a block of information on a single page example
http://css.nu/examples/inline.html http://www.blooberry.com/indexdot/css/examples/ cssembedded.htm
style can be specied for an individual element using STYLE attribute within the element tag loses many of the advantages of style sheets by mixing content with presentation example
6 / 21
Embedded CSS
insert a style sheet into a particular page changing a parameter modies the look of the complete page should be used when a single document has a unique style in the head section by using the <style> tag in the <HEAD> section of document example
7 / 21
8 / 21
CSS Rule
style sheet consists of one or more rules denes how to display HTML element has two parts: selector and declaration syntax
selector { property1: value1; ... }
example
ul ul li { font-size: x-large; font-decoration: italic }
http: //www.htmlhelp.com/reference/css/structure.html
9 / 21
CSS Selector
http://www.w3schools.com/css/css syntax.asp http://www.blooberry.com/indexdot/css/syntax/ selectors/selectors.htm http://www.w3.org/TR/REC-CSS2/selector.html http://www.xml.com/pub/a/2003/06/18/ css3-selectors.html browser table
http://www.westciv.com/style master/academy/ browser support/selectors.html
identies the element to which a style applies variety of forms for selector element selector: refers to HTML element can be grouped together, seperated with comma, and applies therefore to all the listed elements -> H1 {color: purple;} H1, H2, P {color: purple;}
Cascading Style Sheets 10 / 21
11 / 21
CSS Declaration
reference
http://www.htmlhelp.com/reference/css/ all-properties.html
index
http://www.w3.org/TR/REC-CSS2/propidx.html
declaration is combination of property and value enclosed in curly braces divided by a colon syntax
property: value;
property names are not case-sensitive declaration can contain several property/value pairs pairs divided by semicolon
12 / 21
13 / 21
14 / 21
CSS Grouping
grouping of rules makes many rules more manageable example
h1, h2, div.class5, blockquote { background: black }
15 / 21
CSS Inheritance
properties propagate to nested elements can be overridden there style information is inherited downwards the document tree
16 / 21
CSS Media
support for various media: screen, print, projection, braille, speech
17 / 21
CSS1
rst and meanwhile deprecated version http://www.w3.org/TR/REC-CSS1 simple style sheet mechanism that allows to attach style to HTML documents history
dened 1996, 1999
18 / 21
CSS2
builds on CSS1 with very few exceptions, all valid CSS1 style sheets are valid CSS2 style sheets supports media-specic style sheets -> tailor the presentation of document to visual browsers, aural devices, printers, braille devices, handheld devices, .. supports: content positioning downloadable fonts table layout features for internationalization (right-to-left text) automatic counters and numbering table formatting bidirectional text text shadows cursor control printing properties, other media dependies (OS colors, fonts) aural representation (speech synthesizer) history
dened 1998
CSS2 (cont.)
http://www.csszengarden.com/
tutorial
http://www.w3schools.com/css/
reference
http: //zvon.org/xxl/CSS2Reference/Output/index.html
specication
http://www.w3.org/TR/CSS21/
20 / 21
CSS3
under development includes level 2 new selectors vertical text user interaction http://www.w3.org/Style/CSS/current-work
21 / 21