![]() | |
| |
HomeWeb DevelopmentShort ContentsIntroductionCSS Basics Selectors Terminology Colours Fonts Text Blocks Classification Full ContentsIntroductionOther CSS sitesDownload this Guide CSS BasicsSetting Styles...setting values Comments Inheritance Selectors...by class...by id ...contextual Psuedo Classes ...<A> links Psuedo Elements ...first line ...first letter TerminologyCascades"! important" CSS element model Block elements Terminology used here Units ...lengths ...colours ColoursForeground colourBackground ...-color ...-image ...-repeat ...-attachment ...-position FontsFont...-family ...-style ...-variant ...-weight ...-size Textword-spacingletter-spacing text-decoration vertical-align text-transform text-align text-indent line-height Blocksmargin-topmargin-right margin-left margin-bottom margin padding-top padding-right padding-bottom padding-left padding border-top-width border-right-width border-bottom-width border-left-width border-width border-color border-style border-top border-left border-bottom border-right border width height float clear ClassificationDisplaywhitespace list-style list-style-type list-style-image list-style-position |
SelectorsRecall that these are the HTML elements to which style information is applied. However, you can be more specific...Selecting by ClassBy assigning elements "classes", you can use these class names to specify style:<STYLE TYPE="text/css"> H1.classname { ..... } .class2 {style information for all elements with class=class2} </STYLE> ..... <H1 CLASS=classname>This text will be affected by the above SYTLE info.</H1> <H2 CLASS=class2>So is this text</H1> Selecting by IDIt is possible to use the id attribute in HTML tags to specify style information. The element is identified by placingID= in the opening tag. The style information is then specified by using the form
elementname#
ContextualYou can specify that style is only applied to elements which have certain "parents" (elements which they are contained within).e.g. H1 EM { styleinfo }; /*all EM text within a H1 tag*/ UL UL LI { styleinfo }; /*all LI items within two UL sets*/ .classname H1 { styleinfo }; /*all H1 within elements with CLASS=classname*/ #IDname H1 { styleinfo }; /*all H1 text within elements with ID=IDname*/ DIV.IDname H1 { styleinfo }; /*all H1 text within DIV tags with ID=IDname*/ Pseudo-classes and pseudo-elementsNote that in a contextual selector, pseudo-elements are only allowed at the end of the selector.Anchor pseudo-classesStyle can be applied to the three types of anchor links (normal, visited, active), as indicated in the following examples...A:link { The first-line pseudo-element
P:first-line {
The 'first-line' pseudo-element can only be used with a block-level elements, and can only be given the
following property types : font, color, background properties, 'word-spacing' , 'letter-spacing' , 'text-decoration' ,
'vertical-align', 'text-transform' , 'line-height', 'clear' . The first-letter pseudo-element'first-letter' pseudo-elements can have the following properties: font, color, background, 'text-decoration' , 'vertical-align (if 'float' is 'none'), 'text-transform' , 'line-height' , margins, padding, border, 'float' , 'clear' To make a dropcap letter span two lines:P { font-size: 12pt; line-height: 12pt } P:first-letter { font-size: 200%; float: left }The display program (a web browser) defines what characters are inside the 'first-letter' element. Normally, quotes that precede the first letter should be included. Otherwise, the first-letter information is usually ignored if the block starts with a non-letter character. Properties set on 'first-line' will be inherited by 'first-letter', but are overridden if the same property is set on 'first-letter'.
(C)opyright, Geoff Knagge.
Continued use of this site indicates your agreement to the Conditions of use and Privacy Policy. |