stefan and zogo small Help Stefan Campaign
If you can spare $1 then help support this site and change someone's life forever? Learn how and why on the Help Stefan campaign page. Or donate $10 and get my guide to spices book as a gift for your donation!


Celtnet Information:

Introduction to CSS: Part 3

CeltNet CSS Logo

In this section you'll learn a little more about the three main CSS Selector type along with definitions of what they are and examples of what they do. This page will show you all the main types of selectors; including definitions and examples. You may want to bookmark this page to refer back to it as you delve deeper into the intricacies of Cascading Style Sheets.




Tag Selectors

Syntactically an HTML selector is:

HTML Selector {Property:Value;}

A good example of this is the re-definition of the heading style seen in second page of this course:

<HTML>
<HEAD>
<style type="text/css">
h1 {font: 24pt/48pt Monotype Corsiva; margin-top: 1.5px; text-align: center;}
</style>

</head>

<body>
<h1>This is a customized heading!</h1>
</body>

</html>

The effect of using this newly-defined <h1> is as follows:

This is a customized heading!

HTML selectors are employed to redefine the genral look for an HTML tag in your entire website.

CLASS Selectors

Syntactically a Class selector is:

.ClassSelector{Property:Value;}

The following example should make things clearer:

<HTML>
<HEAD>
<style type="text/css">
.headline {font: 24pt/48pt Monotype Corsiva; margin-top: 1.5px; text-align: center;}
</style>

</HEAD>

<BODY>
<b class="headline">This is a bold tag carrying the headline class</b>
<br>
<em class="headline">This is an italics tag carrying the headline class</em>
</BODY>

</HTML>

The effect of using this newly-defined <.headline> class is as follows:

This is a bold tag carrying the headline class
This is an italics tag carrying the headline class

Class selectors are usually used when you want to modify the behaviour of an HTML tag. They can either be defined globally (use the .ClassSelector format) or they can be applied to just a single type of HTML tag (eg p.ClassSelector which only applies as a class to the <p> paragraph HTML tag).

Class Selectors are often used with the special HTML <SPAN> (which is an 'inline-tag' in HTML, meaning that no line breaks are inserted before or after the use of it) and the <DIV> (this is a 'block tag' meaning that line breaks are automatically inserted to distance the block from the surrounding content) tags.

CLASS Selectors

Syntactically a Class selector is:

#IDSelector{Property:Value;}

<html>
<head>
<style type="text/css">
    #layer1 {position:absolute; left:100;top:100; z-Index:0}
    #layer2 {position:absolute; left:135;top:135; z-Index:1}
</style>

</head>

<body>
<div ID="layer1">
<table border="1" bgcolor="#FFCC00"><tr><td>LAYER 1: ID layer1<br>POSITIONED AT 100,100</td></tr></table>
</div>

<div ID="layer2">

<table border="1" bgcolor="#00CCFF"><tr><td>LAYER 2: ID layer2<br>POSITIONED AT 140,140</td></tr></table>
</div>
</body>
</html>

As the example above uses layers, please click here to show the results in a new window.

ID selectors are used to define a style that relates to an object with an unique ID. As such they can only be called once in a single HTML pages. For this reason ID Selectors are most widely used with layers (as shown above). This is a good match, as layers are always defined with an unique identifier.

The next part of this CSS course will tell you more about CSS styles and how they actually apply to HTML elements. If you are interested in following this course, of if you want to brush-up your CSS programming skills then I suggest that you buy yourself a book on CSS and HTML (a number of possible options form Amazon are shown at the bottom of this page).

On to the next part...

Search: css html internet


In association with Amazon.co.uk
  

1.
Search : CSS: The Missing Manual
List Price: £24.99
Amazon.co.uk's Price: £17.49
You Save: £7.50 (30%)
Prices subject to change.
CSS: The Missing Manual
by: David McFarland
August 24, 2006
 
2.
Search : Dreamweaver CS3: The Missing Manual
List Price: £31.99
Amazon.co.uk's Price: £19.51
You Save: £12.48 (39%)
Prices subject to change.
Dreamweaver CS3: The Missing Manual
by: David McFarland
June 22, 2007
 
3.
Search : JavaScript: The Definitive Guide
List Price: £35.50
Amazon.co.uk's Price: £23.08
You Save: £12.42 (35%)
Prices subject to change.
JavaScript: The Definitive Guide
by: David Flanagan
August 17, 2006
 
4.
Search : HTML for the World Wide Web: with XHTML and CSS: With XHTML and CSS (Visual QuickStart Guides)
List Price: £21.99
Amazon.co.uk's Price: £10.99
You Save: £11.00 (50%)
Prices subject to change.
HTML for the World Wide Web: with XHTML and CSS: With XHTML and CSS (Visual QuickStart Guides)
by: Elizabeth Castro
August 31, 2006
 
5.
Search : Bulletproof Web Design: Improving Flexibility and Protecting Against Worst-Case Scenarios with XHTML and CSS
List Price: £28.99
Amazon.co.uk's Price: £14.49
You Save: £14.50 (50%)
Prices subject to change.
Bulletproof Web Design: Improving Flexibility and Protecting Against Worst-Case Scenarios with XHTML and CSS
by: Dan Cederholm
August 23, 2007
 
6.
Search : HTML, XHTML, and CSS All-in-one Desk Reference for Dummies (For Dummies)
List Price: £22.99
Amazon.co.uk's Price: £11.49
You Save: £11.50 (50%)
Prices subject to change.
HTML, XHTML, and CSS All-in-one Desk Reference for Dummies (For Dummies)
by: Andy Harris, Chris McCulloh
May 09, 2008
 
7.
Search : Creating Web Sites: The Missing Manual
List Price: £20.95
Amazon.co.uk's Price: £14.67
You Save: £6.28 (30%)
Prices subject to change.
Creating Web Sites: The Missing Manual
by: Matthew MacDonald
October 26, 2005
 
8.
Search : The CSS Anthology: 101 Essential Tips, Tricks and Hacks
List Price: £24.99
Amazon.co.uk's Price: £23.74
You Save: £1.25 ( 5%)
Prices subject to change.
The CSS Anthology: 101 Essential Tips, Tricks and Hacks
by: Rachel Andrew
August 01, 2007
 
9.
Search : CSS Mastery: Advanced Web Standards Solutions
List Price: £23.99
Amazon.co.uk's Price: £19.19
You Save: £4.80 (20%)
Prices subject to change.
CSS Mastery: Advanced Web Standards Solutions
by: Andy Budd, Cameron Moll, Simon Collison
February 01, 2006
 
10.
Search : HTML, XHTML and CSS for Dummies (For Dummies)
List Price: £19.99
Amazon.co.uk's Price: £9.99
You Save: £10.00 (50%)
Prices subject to change.
HTML, XHTML and CSS for Dummies (For Dummies)
by: Ed Tittel, Jeff Noble
June 06, 2008
 
page 1 of  13
 1  2  3  4  5  6  7  8  9  10  11 
 



Domain Name Registration




Quick Links:
Make Money from the Web
Essential Web Tools
Generate your Website
Paid Surveys
Affiliate Programmes
Successful Affiliates
Maximizing Traffic
News Feeds
Using Minisites
Form-mail script
Sitemap
Links
Celtnet Information Home


Site Search





[Valid RSS] Register Domains
Copyright © 2005–2007, Dyfed Lloyd Evans