Home Surf the web Anonymously My public bookmarks phpshift.info Promote yourself free Free 1GB Online Storage

CSS: Overview

Introduction - What is CSS?

Cascading Style Sheets (CSS) are a way for web page designers to make web pages look pretty. They use CSS to enhance the visual appeal of web documents. Once upon a time, web pages used to be enhanced with Hypertext Markup Language (HTML) code, but this grew to become very tediuos and made HTML files too large. It also made updating or redesigning pages quite an arduous task. CSS was invented to alleviate these problems and leave HTML for just markup (ie. content and images) and use CSS for presentation (ie. fonts, colours, shapes, borders, margins, etc.)

How can we use CSS?

There are several ways a web author can write a CSS document. The first is directly inside an exisiting HTML document. This is called an embedded stylesheet. Another is to write the code directly beside any HTML elements (ie <b>, <table>, etc.) This tends to increase the size of the HTML files which defeats the purpose of using CSS. The best way to use CSS is to create an external style sheet. You type out your HTML code in a .html document, and type out all of the CSS code in a .css text file. An external style sheet has many advantages over an embedded style sheet. The first is you can change the look of an entire website full of hundreds of documents by changing only one file (the .css file(s)) without having to change each and every .html document. The second, is that all browsers will cache the .css document, and use it for all .html documents that request it without having to download it each time a new page is loaded. This results in fast browsing for your audience.

All of these things make for a better experience. All the presentational markup can be made in only one or two .css files, elminiating the need to include it in all your HTML documents and creating smaller file sizes. Also, you can change the look of your whole site with a few modifications to your .css files. Lastly, .css documents are cached and can be used by the browser again and again without needing to retrieve them from the server each time a new page is loaded.

Syntax

CSS is a very easy language to learn, read and understand. All of it is based on U.S. English. If you can speak English well, or are learning, CSS should be very easy for you.

Validate your CSS Make sure all your code complies with internet standards. To prevent and elminiate any problems with different browsers and user agents, visit CSS Validator.