CSS Codes
From LoveToKnow Web-Design
An vital tool for any web designer in the web 2.0 world is the ability to work with CSS codes. This method and tool for web design is a way to keep layout and content separate, which is essential in the the era of "write once, display anywhere" methodology.
Why Use CSS Codes in the First Place?
What is the advantage of learning this new coding method? Aside from the holy grail of content management, it simply makes life easier. As will be seen, entire websites can have their look and feel for thousands of pages dictated by a single CSS document. This means that when the client suddenly changes its corporate colors from green and purple to black and silver, instead of changing thousands of pages only one – the CSS document – needs to be changed.
It applies to a lot more than color – site interaction, paragraph layout, character fonts, page size and many more things can be controlled through CSS. It's a tool only limited by the imagination and coding skill of the person writing it.
There is also a benefit in terms of speed of page loading, since each page takes less formatting tags (such as <font>). This results in faster page loading times for the viewers, and less time for the web designers to format the pages, which means more content can be produced in less time…in short, everybody wins.One reason not to use CSS codes is that not all browsers actually support them consistently. There are many ways to work around the problem, but currently this does cut into the time saved in coding the web page.
The Style Element
Every HTML document has a separa tag, or the color of the text in the emphasis tag# '''The value''' of the property (in the above example, it would be a color like "red" for the emphasis tag.
Each tag is not limited to only one rule; the emphasis tag could have more than one:
em { color: green }<br>
em { size: larger}
So an example of a whole style element, within the context of a web page, would look like the following:
<pre>
<head>
<style type="text/css">
body {
padding-left: 11em;
font-family: Arial, Helvetica, sans serif;
color: green;
background-color: #FFFFFF }
em {
font-style: bolder;
color: red}
</style>
</head>
Note that there are other elements of the header that should go on, such as the
Separating the Content
While it's fine to set up the css in the head of the page (and this is especially useful for pages that need to look different than the rest of the site) it tends to get crowded. A full set of rules to cover all tags can run many, many lines of code. And at that point the page is once again becoming cluttered and filled with things that are not needed.
To really experience the magic of CSS codes, the style selectors should be put in a separate file, usually with the suffix ".css" (as opposed to .html or the like). No other tags such as head or style are necessary – just start the page with the first tag to be modified and go about defining the rules and selectors.
However, at that point the page that references the .css page must be defined. That is done again in the head element on the page, but with a simple tag definition:
<link rel="stylesheet" href="pathToStyleSheet.css">where the "pathToStyleSheet.css" would be the page created with all the rules. When the site needs to be changed, only the .CSS codes need to be changed – all the other pages that reference it will automatically be switched.
This document only scratches the surface of the creation of cascading style sheets, but with a solid background on the principles and some research in other design articles, implementation of this time and bandwidth-saving technique is fast and easy.
This page has been accessed 282 times. This page was last modified 05:11, 3 June 2008.
© 2006-2008 LoveToKnow Corp.
