Tutorials & Script Homepage
Style Sheets 7to13
Syntax: Part 1
Syntax: Part 2
Syntax: Part 3
Syntax: Part 4
Different Types of Style Sheets
CSS Shorthand
Style Inheritance
advertisment
advertisement
advertisement
Host With Us: HostingHelper.co.uk From Only $5.00p/m
Spotted an Error ? Let us Know
100's more FREE templates at FreeWebTemplates
Looking for a new Web Host ?
Free templates from TemplatesLand
Professional High-End Templates
TemplateBox.com more FREE templates
Free Flash Templates and Intros
advertisement
 
STYLE SHEETS NUMBER : 10
Please Click Here, and Help Keep This Site FREE to Use
 
Please click on our sponsors advert to the right if you download or use anything from this page.
Thank you for your help.

CSS Syntax (Part 4)

First Line Pseudo-element
Often in newspaper articles, such as those in the Wall Street Journal, the first line of text in an article is displayed in bold lettering and all capitals. CSS1 has included this capability as a pseudo-element. A first-line pseudo-element may be used in any block-level element (such as P H1 , etc.). An example of a first-line pseudo-element would be:

	P:first-line { font-variant: small-caps; 
	               font-weight: bold }

First Letter Pseudo-element
The first-letter pseudo-element is used to create drop caps and other effects. The first letter of text within an assigned selector will be rendered according to the value assigned. A first-letter pseudo-element may be used in any block-level element. For example:

	P:first-letter { font-size: 300%; float: left }

would create a drop cap three times the normal font size.

Cascading Order
When multiple style sheets are used, the style sheets may fight over control of a particular selector. In these situations, there must be rules as to which style sheet's rule will win out. The following characteristics will determine the outcome of contradictory style sheets.

1. Important
Rules can be designated as important by specifying ! important. A style that is designated as important will win out over contradictory styles of otherwise equal weight. Likewise, since both author and reader may specify important rules, the author's rule will override the reader's in cases of importance. A sample use of the ! important statement:

	BODY { background: url(bar.gif) white;
	       background-repeat: repeat-x ! important }

2. Origin of Rules (Author's vs. Reader's)
As was previously mentioned, both authors and readers have the ability to specify style sheets. When rules between the two conflict, the author's rules will win out over reader's rules of otherwise equal weight. Both author's and reader's style sheets override the browser's built-in style sheets.

Authors should be wary of using ! important rules since they will override any of the user's ! important rules. A user may, for example, require large font sizes or special colors due to vision problems, and such a user would likely declare certain style rules to be ! important, since some styles are vital for the user to be able to read a page. Any ! important rules will override normal rules, so authors are advised to use normal rules almost exclusively to ensure that users with special style needs are able to read the page.

3. Selector Rules: Calculating Specificity
Style sheets can also override conflicting style sheets based on their level of specificity, where a more specific style will always win out over a less specific one. It is simply a counting game to calculate the specificity of a selector.

a. Count the number of ID attributes in the selector.

b. Count the number of CLASS attributes in the selector.

c. Count the number of HTML tag names in the selector.

Finally, write the three numbers in exact order with no spaces or commas to obtain a three digit number. (Note, you may need to convert the numbers to a larger base to end up with three digits.) The final list of numbers corresponding to selectors will easily determine specificity with the higher numbers winning out over lower numbers. Following is a list of selectors sorted by specificity:

	#id1         {xxx} /* a=1 b=0 c=0 --> specificity = 100 */
	UL UL LI.red {xxx} /* a=0 b=1 c=3 --> specificity = 013 */
	LI.red       {xxx} /* a=0 b=1 c=1 --> specificity = 011 */
	LI           {xxx} /* a=0 b=0 c=1 --> specificity = 001 */

4. Order of Specification
To make it easy, when two rules have the same weight, the last rule specified wins.

CSS Syntax (Part 1) | CSS Syntax (Part 2) | CSS Syntax (Part 3) CSS Syntax (Part 4)

Web Hosting  |  Membership website templates  |  Reliable UK Web Hosting  |  dresses  |  Art Web Templates  |  Cheap Flight Deals  |  UK Web Hosting Company  |  Coursework Writing  |  Reseller Hosting  |  coches de ocasion  |  Cheap UK Web Hosting  |   cell phones  |  Web Design  |  Low Cost Domain Names  |  Website templates  |  master a distancia  |  Austin Web Design  |  Flash Templates  |  Factory  |   cell phones  |  Canadian Web Hosting  |  Flash Intros  |  Web Templates  |  cartuchos  |  Corporate Logo Design Service  |  Website Templates  |  Bespoke Software Development  |  Domain Name Registration  |  Free Website Templates  |   Dedicated Server  |  UK Web Hosting  |  Dating Software - aeDating 4.1  |  Website Templates  |  Power Saver  |  taobao agent  |  Flash templates  |  cctv cameras  |  Lolita Dresse  |  china wholesale  |  Canadian Web Hosting  |   Cheap Web Hosting Deal  |  Linux Hosting  |  Web Design uk  |  Web Hosting  |  Business web directory  |  Electronics  |  Free domain names  |  Best UK web Hosting  |  Shower Enclosures UK  |  

 
advertisment
advertisment
advertisment
  Top-end templates
  Flash Templates
  Web Hosting UK
  Made-in-China.com
  Web Design Tips
  Web Hosting Reviews
  Web hosting reviews
  Website Design
  Top web hosting
  Stock Photography
  Bildagentur
  Reseller Hosting
  Company Logos
  Website Templates
  Website Templates
  Web Hosting UK
  templatebox.com
  freewebtemplates.com
  templatesland.com
  topfreegraphics.com
  freegraphicland.com
  free-templates-layouts
  Logo Design Software
  Layouts4Free
  Webmaster Resoucres
  Web Templates Factory
  Free Web Templates
  Free Templates Catalog
  Web Templates
  Reseller Web Hosting
  Stock Photography
  Animations-galore.com
  4print.com.au
  Host Review
  Web Hosting Host Color
  Dedicated Servers
  FlashTemplateDesign
  ZeroDollarTemplates
  Killersites.com
  how-to-build-websites
  Build a free website
  web Hosting
  Business Logo Design
  Templates Favpage
  webmastermind.de
  flasheasy.com
  More Featured Sites