CSS Styles Tutorial
Tool(s) Required:
HTML Editor: Any
Recommended: Adobe Dreamweaver CS3
Introduction
Cascading Style Sheets (CSS) are a collection of formatting rules that control the appearance of content in a web page. They are very useful for maintaining a web site since its appearance (controlled by properties of HTML tags) can be managed from just one file. CSS Styles also enhance your site's look, accessibility and reduces file size. Another main advantage is reusability - instead of defining the properties of fonts, backgrounds, borders, bullets, uniform tags, etc. each time you use them you can just assign the corresponding css style in the class property. You can store CSS styles directly in each document or, for more control and flexibility, in an external style sheet.
There are 3 types of CSS Styles:
- Custom CSS (Class) styles: create a customized style with the set attributes. These class styles can be applied to any tag.
- HTML Tag styles: redefine the formatting for a particular tag, such as <h1>. All text formatted with the h1 tag is immediately updated.
- Advanced CSS Selector styles: redefine the formatting for:
- A particular combination of tags (for example, td h2 applies whenever an h2 header appears inside a table cell) and pseudo-class styles (for example, a:link, a:hover, a:visited)
- A specific ID attribute (for example, #myStyle applies to all tags that contain the attribute-value pair id="myStyle")
How it works
CSS styles are defined within the <style> tag.
If you define the styles embedded within your current document you will find code similar to the following in your head content:
<!--
.bluetext {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #000066;text-decoration: none;} -> Example of Class style:- apply using class property for any tag <p class="bluetext">
h1 {specifications} -> Example of Tag style:- for tag <h1>
a:link {specifications} -> Example of pseudo-class Advanced style:- applied to all <a> tags without any other style
#NewsBox {specifications} -> Example of ID attribute Advanced style:- applied to the tag whose ID property is set to NewsBox
-->
</style>
If you define the style in a external existing or new Style Sheet (recommended) you will find code similar to the following in your head content:
This code indicates that the document is linking to the external style sheet called styles.css located under the site root. If you open the style sheet in notepad you will find code similar to the code for the styles being embedded in the document. The big advantage of external style sheets is that the web site is easy to maintain and that when we make changes to the styles applied in the document, only the style sheet needs to be uploaded and not all the pages accessing it. As a practice, while using Macromedia Dreamweaver, link you template(s) to the external style sheet so that all the pages using the template can use just one style sheet.
Creating a New Style Sheet and a new CSS Style
Open your site in Dreamweaver and do the following:
- Open any page of your site and select window > CSS Styles and Click the New CSS Style button (+ icon), a pop-up window will show up.
- Select Class in the Selector Type. Now type your style name in the Name box (example: .bullet). Use the Tag Selector Type for redefining HTML tags or the Advanced Selector Type for hovers, id attributes or combination of tags.
- Define the style in a New Style Sheet, give a name (example: styles.css) and save it under your site root. Click OK.
- In the CSS Style Definition pop-up window that appears give the Formatting Attributes like Font, List, Background, Border, Positioning, etc.
Applying the New Style
- To use this style just select and right click any tag in the tag selector located at the bottom left of the Document window. For the Set Class attribute select bullet from the list.
- While typing the HTML code use styles by setting the class property for any tag (example: <ol class = "bullet">).
Our Tutorial on Cool Text Effects using CSS Styles teaches the following:
- Text Links Rollover
- Text Case Setting
- Text Spacing
- Line-through Effect
Our Tutorial on using Bullets in HTML or Macromedia Deamweaver teaches how to use CSS Styles with bullets (shapes, decimal, roman-numerals, alphabetical and images).
Our Tutorial on Links without Underline teaches how to use CSS Styles to display links without the appearance of the underline.
Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!
FREE Flash Actionscript & Animation Guide
Learn Flash the easy way using these easy-to-follow tutorials! Get your basics right or learn advanced flash actionscript!
Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization
This page is part of the SmartWebby's Free Web Design Guide, a collection of free web design tutorials, articles, tips and guidelines on effective web site design. From web design tips and ideas to HTML, CSS Styles, Fireworks and Dreamweaver you'll find all you need to know about web design right here!
SmartWebby.com provides top-quality web design & web programming services globally. Since January 2001, we have successfully built more than 200 professional web sites for clients from all over the world (USA, UK, Canada, Australia, India, Greece, Denmark, Singapore, etc.). By creating highly professional W3C Standard compliant and load-time optimized websites at extremely affordable prices, we leave our competition far behind in terms of "value for money". We specialize in Rapid Web Design using Adobe Tools, ASP.net/ASP/PHP web programming, W3C Standard compliant CSS & HTML programming, high quality Flash Animation and Interactive Flash Programming. No matter what your requirements are, our team is capable of delivering a website that's over & above your expectations. Check out our popular Web Design Packages today!

