Welcome, Guest

Please login or register

TUTORIALS SUBMENU ---->

PHOTOSHOP    FLASH    ILLUSTRATOR    BLENDER    CINEMA 4D    WEB-CODING

Related Links

An Introduction to CSS

pages (2): [1] 2


If you are a web designer and haven't been living in a cave for the last few years, then you must have heard of the amazing CSS technology! CSS is short for 'Cascading Style Sheets', and is a part of current web standards. Quite simply, it allows you to define your entire design from one simple document, making templates an utter doddle to set up and maintain.  To help you get to grips with the new technology, this tutorial covers the basics of CSS setup, and helps get you well on your way to a more complete understanding of the CSS methodology.


Section 1: The Basics
Style sheets come in two distinct flavours - internal (i.e. the CSS definitions are part of the source HTML document), and external (i.e. All CSS definitions are in a separate file).  For the sake of this tutorial we will be exploring external stylesheets only.  All you need are two files - yourfile.html and yourfile.css.  Put your CSS definitions in the .css file as simple text, and the HTML in the .html document. Section 4 will tell you how to link the files together.

body{ background-color:#000000; }

This small snippet is the CSS code to change the background color of your web site. Looking at it, we can break it up into a number of different components:

  1. 'body' - This tells the browser what is going to be affected. Using 'body' means that all <body> tags will have this style. This can be changed to any html tag. To have it apply to multiple tags separate each with a ','. Eg. body, font, td

  2. '{' and '}' - The curly brackets encase all of the attributes assigned.

  3. 'background-color:' - 'background-color' is one of the many CSS attributes. It defines the objects background color, similar to the HTML attribute 'bgcolor'. Notice that it is followed by a colon ':'. All CSS attributes will have this colon.

  4. '#000000' - This is the user-defined part of the attribute. Enter any six digit hexadecimal color value here. #000000 will produce a black background.

  5. ';' - The semicolon is very important. It is the closing tag for all CSS attributes and is needed the browser to tell when old attributes end and new ones begin.

Here is another example showing the syntax for using more than one attribute:

body{ background-color:#000000; font-family:Arial, Helvetica, sans-serif; font-size:12px; }

 

Section 2: The Class
If you want to define unique sets of variables for various uses (i.e. a 'bigtext' class for headings, and a 'specialtext' class for important text sections), then you will have to make use of classes.  These are defined as follows:

The CSS:

.bigfont{ font-family:Arial, Helvetica, sans-serif; font-size:40px; }
  1. '.' - The dot says that you are starting to declare a class.
  2. 'bigfont' - This is the user-defined name for the class. Call it whatever you want.
  3. '{font-family:Arial, Helvetica, sans-serif; font-size:40px;}' - As with example 1, these are the user-defined attributes enclosed by curly brackets.

The HTML:

<font class="bigfont">This is big text.</font>

Now I'll explain CSS classes. Here is a rundown of the different components:
  1. 'class="bigfont"' - Here is where you select the class you want to use (and, hence, what attributes you want to apply to the font).

Classes are very useful because they can be used an infinite number of times, and can apply to whatever HTML tag takes your fancy (unless, of course, you declare attributes for a specific tag, which will be explained later).  Just to make sure you have been listening, though, here's a few more examples:

Example 1:

<td class="bigfont"> <font class="bigfont">This is big text inside a <td> with the same class applied.</font> </td>


Example 2: Here is an example of a class made specifically for a <font> tag. Notice the only difference is the preceding word 'font' before the '.'.

The HTML:

font.bigfont{ font-family:Arial, Helvetica, sans-serif; font-size:40px; }

The HTML:

<font class="bigfont">This is big text.</font>

- Tutorial written by Gus Mayo

Pages (2): [1] 2 Next>
Automatic Translations: Translate Into French Translate Into German Translate Into Italian Translate Into Spanish Translate Into Portuguese
Featured Content

Electrical Circuits
Electrical Circuits
- Adobe Photoshop -
Type Along A Path
Type Along A Path
- Adobe Photoshop -
Creating Warm Light
Creating Warm Light
- Adobe Photoshop -
Shiny Spheres
Shiny Spheres
- Adobe Photoshop -
Membership

Username:
Password:  
Remember Me

Lost Password? || Register

Special Options
Printer Friendly Version
Forum Threads

Competition Discussion - Brushes
Author: Man1c M0g
Posted: Feb 07th, 5:48pm
Activity: 0 replies, 54 views
 Competition - Brushes
Author: Man1c M0g
Posted: Feb 07th, 5:46pm
Activity: 0 replies, 56 views
 PM Spamming
Author: Tamlin
Posted: Feb 06th, 1:24pm
Activity: 7 replies, 119 views
Vector Clipart Bank
Author: Crapoun
Posted: Feb 06th, 11:29am
Activity: 2 replies, 94 views
How did ...
Author: MoodsR4Cattle
Posted: Feb 05th, 6:09pm
Activity: 6 replies, 28 views
Tips and trick for Texturing/Materials
Author: noorjan
Posted: Feb 05th, 4:59am
Activity: 2 replies, 112 views
 A Billion Styles - Please Help Me!!
Author: Angelz
Posted: Feb 03rd, 6:36pm
Activity: 2 replies, 137 views
101 Things you didnt know in 3DS Max ...in fact...
Author: noorjan
Posted: Jan 31st, 6:04pm
Activity: 0 replies, 163 views
Pee Wee get's an IPad
Author: MoodsR4Cattle
Posted: Jan 30th, 4:25pm
Activity: 2 replies, 164 views
Spam :: Online hotel reservations for Hotels in...
Author: kieulinh
Posted: Jan 28th, 6:39am
Activity: 0 replies, 205 views
New Design
Author: unleash
Posted: Jan 23rd, 12:39am
Activity: 3 replies, 17 views
New Design
Author: unleash
Posted: Jan 23rd, 12:39am
Activity: 27 replies, 727 views
Forum Threads

--- Site Resources ---
Total Tutorials:212
Total Downloads:    415