Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Understanding Style Sheets (part 1)
Learn how to create and use style sheets across your Web site

| Into The Light |

Let's start off with a simple example. Consider this HTML page:


<HTML>
<HEAD>
</HEAD>

<BODY>

Q. How many <B>developers</B> does it take to change a <B>light bulb</B>?
<P>
A. The light bulb works <B>fine</B> on the <B>system in my office...</B>

</BODY>
</HTML>


As you can see, certain words in the text above have been emphasized in bold. Now, let's suppose that you also wanted to change the text colour of these emphasized words...to green, maybe? Normally, you'd do something like this:


<HTML>
<HEAD>
</HEAD>

<BODY>

Q. How many <B><FONT COLOR="Lime">developers</FONT></B> does it take to change a <B><FONT COLOR="Lime">light bulb</FONT></B>?
<P>
A. The light bulb works <B><FONT COLOR="Lime">fine</FONT></B> on the <B><FONT COLOR="Lime">system in my office...</FONT></B>

</BODY>
</HTML>


Imagine, then, how much simpler it would be if you could just use a style sheet.


<HTML>
<HEAD>
<STYLE TYPE="text/css">
B {color: lime}
</STYLE>

</HEAD>

<BODY>

Q. How many <B>developers</B> does it take to change a <B>light bulb</B>?
<P>
A. The light bulb works <B>fine</B> on the <B>system in my office...</B>

</BODY>
</HTML>


The two examples will look identical when you view them in a browser - however, the second one has the distinct advantage of being much easier to read. Take it one step further - if you suddenly wake up in the middle of the night with visions of the colour #CC6633 dancing in your mind, the second example allows you to change the colour of all emphasized words in one fell swoop. Take a look.


<HTML>
<HEAD>
<STYLE TYPE="text/css">
B {color: #CC6633}
</STYLE>

</HEAD>

<BODY>

Q. How many <B>developers</B> does it take to change a <B>light bulb</B>?
<P>
A. The light bulb works <B>fine</B> on the <B>system in my office...</B>

</BODY>
</HTML>


Thus, by separating design from code, style sheets can substantially reduce the amount of time you spend making changes to your site...which, when you come to think about it, is exactly the way it should be.


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback