CSS (Cascading Style Sheets) have been around for a while now, and act as a complement to plain old HTML files. Style sheets allow a developer to separate HTML code from formatting rules and styles. It seems like many HTML beginners’ under-estimate power and flexibility of style sheet. In this article, I’m going to describe what cascading style sheets are, their benefits, and two ways to implement them.--------------------------------------- Cascading whats? ---------------------------------------
Cascading Style Sheets…that’s what! They’re what paint is to canvas, what topping is to ice cream… they complement HTML and allow us to define style (look and feel) for our entire site in just one file!
Cascading style sheets were introduced to web development world way back in 1996. They get their name from fact that each different style declaration can be “cascaded” under one above it, forming a parent-child relationship between styles.
They were quickly standardized, and both Internet Explorer and Netscape built their latest browser releases to match CSS standard (or, to match it as closely as they could).
So, you’re still asking what a style sheet exactly is? A style sheet is a free-flowing document that can either be referenced by, or included into a HTML document. Style sheets use blocks of formatted code to define styles for existing HTML elements, or new styles, called classes.
Style sheets can be used to change height of some text, to change background color of a page, to set default border color of a table…the list goes on and on. Put simply though, style sheets are used to set formatting, color scheme and style of an HTML page.
Style sheets should be used instead of standard , , and tags because: - One style sheet can be referenced from many pages, meaning that each file is kept to a minimum size and only requires only extra line to load external style sheet file
- If you ever need to change any part of your sites look/feel, it can be done quickly and only needs to be done in one place: style sheet.
- With cascading style sheets, there are many, many page attributes that simply cannot be set without them: individual tags can have different background colors, borders, indents, shadows, etc.
Style sheets can either be inline (included as part of a HTML document), or, referenced externally (Contained in a separate file and referenced from HTML document). Inline style sheets are contained wholly within a HTML document and will only change look and layout of that HTML file.
Open your favorite text editor and enter following code. Save file as stylesheet.html and open it in your browser:
Cascading Style Sheet Example < itle> This is one big H1 tag!
When you fire up your browser, you should see text "This is one big H1 tag!" in a large, blue Verdana font face.