Academic Tutorials

English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting

CSS 2.0
CSS 2.0 Introduction
CSS 2.0 Attaching Style
CSS 2.0 Applying Style
CSS 2.0 Key Concepts
CSS 2.0 Color Contents
CSS 2.0 Fonts Contents
CSS 2.0 Text
CSS 2.0 Lists
CSS 2.0 the box model
CSS 2.0 Advanced concepts
CSS 2.0 Positioning
CSS 2.0 Boxes
CSS 2.0 Generated content
CSS 2.0 Dynamic effects
CSS 2.0 Tables
CSS 2.0 Paged media
CSS 2.0 Font Face
CSS 2.0 Aural Style Sheets
CSS 2.0 Language styles

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
Apple Script
PL/SQL Tutorial
SQL Server
.NET (dotnet)
.Net Mobile
C# : C Sharp
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Assembly Language
Forth Programming
Lisp Programming
Data Warehousing
CGI Programming
Emacs Tutorial
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Operating System
Software Testing
SAP Module
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Financial Accounting
Managerial Accounting
Network Sites

Applying style to pages Contents

Previoushome Next

Applying style to pages Contents



Declarations are used to apply style to elements, for example, to set an element to have a border.

The basic syntax of a declaration is a property (such as color) followed by a colon (:) and a value. Thus color: red is a declaration. Declarations are directly used only in inline style.

Declaration grouping

In order to specify several styles for an element, declarations can be separated by semi-colons. For example, <P style="color: red; font-size: 16px;">. It is optional to have a semi-colon after the final declaration - <P style="color: red; font-size: 16px"> is also valid.


Selectors are used to associate style declarations with an element or elements.

This is done by placing the declarations within a block (enclosed in {}) and preceding it with a selector. For example, to associate the color: red declaration with all P elements, you would place that declaration in a block and add a selector that matches P:

P {color: red}

The example below would make all 'DIV' elements red and 16 pixels high:

DIV {color: red;
font-size: 16px}

At its most basic, a selector consists of an element name (for example, <P>) (without the < and >). Selectors such as P or A:link are called simple.


The type selector


The CSS selector involves taking the HTML element, removing the < and >. It is used, as previously explained, in an example such as BODY {color: red}.

Class selectors

These allow you to group elements in a class. For example, (if you've got CSS in your browser) you will see all the code exerpts have a gray background with black border. This is due to a class.

The HTML code for a class looks like this <TAG class="classname">. For example:

<P class="introductoryparagraph"> .... </P>

These are distinguished in the style sheet by the use of a period followed by the class name:

P.introductoryparagraph {color: blue}

This applies to P elements with a class of introductorypargraph.

.introductoryparagraph {color: blue}

This would apply to any element with a class of introductoryparagraph (the other one would only apply to P elements).

Class names should describe the content of the element - instead of class="italic" you should say why you want it to be italic, e.g. class="copyrightnotice". That way your style sheet will be self-documenting, and you can easily change appearance according to element content.

Classes may not start with a number or hyphen, and should be in lowercase (because although all browsers should distinguish between lower and upper case, most do not). They may not contain spaces in their names. They may contain any letter of the alphabet as well as numbers and hyphens (but not at the start of the class).

An element may have more than one class, e.g., <P class="green quote new"> matches, e.g.,, or, but not However, few browsers support this use.

Pseudo-class selectors

These are so called because the behavior is as if the element was specially marked as that class.

Note that pseudo-class selectors that cause the document to reflow may be ignored by web browsers. An example of this would be a different font size on a visited link to an unvisited one.

:link, :visited

These apply to unvisited, and visited links respectively. A link cannot be both visited and unvisited. E.g.:

A:link {color: red} /* :link would be the same as A:link, because there aren't any other elements to which :link applies */
A:visited {color: purple}

:hover and :focus selectors

Hover applies when a mouse is over an element, and focus when the element has the focus; e.g., a value being typed in a form field. For example, P:hover {text-decoration: underline}, or A:focus. Hover and focus are not mutually exclusive with each other or with :link and :visited.

:active selectors

This applies to an element being activated. For example, INPUT:active {color: red} would make INPUT elements in the process of being activated red.

Links can be active as well as linked or visited. In addition, :active applies to all elements - not just links.

Pseudo-classes on links


A:active {background-color: red}
A:hover {background-color: yellow}
A:link {background-color: green}

Presumably the intention would be to have unvisited links green, except when a mouse is hovering over it, when the desired background color is yellow, and when it is being activated, when the background color should be red.

However, this would not happen, because the states are not mutually exclusive, and since A:link comes last, it overrides the previous ones.

In order to specify more about an element, you can use multiple pseudo-classes; for example, A:link:hover. Thus to specify that you want hovered over unvisited links with the focus to be red, you would say A:link:hover:focus {color: red}. Note that only Netscape 6, and not Windows Internet Explorer, supports this usage.

Contextual selectors

These provide that if ELEMENT2 is a descendant of ELEMENT1, then the given properties apply to those ELEMENT2s. E.g.:

STRONG EM {text-transform: uppercase} /* EM inside STRONG will be uppercase */

This is a very important concept indeed. To take an example, the links in the contents tables at the top of this page are enclosed in <DIV class="contents"></DIV>. That means that to make the links a different color you can just type DIV.contents A {color: blue}, which is equivalent to specifying that you want all links (all A elements) inside the DIV to be blue.

Selector grouping

In order to associate a block with several different selectors, and therefore save typing and download time, one can separate the selectors by commas.

BODY P, H1 {color: red}

is the same as:

BODY P {color: red}
H1 {color: red}

Be the first one to comment on this page.

  CSS 2.0 eBooks
More Links » »
 CSS 2.0 FAQs
More Links » »
 CSS 2.0 Interview Questions
More Links » »
 CSS 2.0 Articles

No CSS 2.0 Articles could be found as of now.

 CSS 2.0 News

No News on CSS 2.0 could be found as of now.

 CSS 2.0 Jobs

No CSS 2.0 Articles could be found as of now.

Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: Applying style to pages Contents, CSS2, css2, CSS2 tutorial, CSS2 tutorial pdf, history of CSS2, Custamizing Style Sheet, learn CSS2

HTML Quizzes
CSS Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
XML Quizzes
XML Quiz
XSL Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright ? 2008. Academic All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World | Important Websites
Copyright ? 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.