Academic Tutorials



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

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
HLML
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
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
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
Accounting
Financial Accounting
Managerial Accounting
Network Sites


Applying style to pages Contents


Previoushome Next






Applying style to pages Contents

A D V E R T I S E M E N T



Declarations

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

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.

Selectors

The type selector

BODY

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., P.quote.green, P.new or P.quote.new.green, but not P.new.old. 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

Consider:

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
  • del.icio.us
  • De.lirio.us
  • 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
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL 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
JBOSS 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
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP 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 Tutorials.com. 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
Copyright 2003-2017 Vyom Technosoft Pvt. Ltd., All Rights Reserved.