Cascading Style Sheets Example
There are three parts to a CSS statement
- selector
- property
- value
Each statement is written like the following:
selector {property: value}
There are three kinds of selectors:
- elements
- classes
- ids
Elements refer to basic HTML tags: a, img, p, body, div, etc.
Classes are defined selectors. A class is defined by a . (period) and a name:
- .right
- .left
- p.readmore
Classes are used to further define already existing elements.
ID are defined selectors as well. Typically they are used to define DIVs. An ID should be used when the element is going to appear or be used only once.
- .right
- .left
- p.readmore
The screenshot below shows a small example from a cascading style sheet. Each part is labled accordingly.
If you want to examine a full length css document, I would suggest the following:
- Go to Open Source Web Design
- Click Search Designs
- Select XHTML 1.0 Srtict under validation
- Select Yes under CSS
- Click Search
- A list of designs will show on the screen. You can view each design and download it.
- Download a few designs. It doesn’t matter what it looks like if all you’re after is understanding what a style sheet looks like.
- The downloaded designs will contain a .css file.
- Open the file in a text editor and learn away!
- Other designs can be found at Open Web Design following similar steps as above.
[tags]css, cascading+style+sheets, webdesign, development[/tags]
About the Author
Paul Flyer loves to research the web and find resources and tools for building, maintaining and promoting websites. Based in Saint Louis, MO, he works in management and spends his free time sharpening his web development and copy writing skills. Feel free to contact Paul with any questions, comments or ideas. He is also available to help you with your own website.
Popular Articles
- Removing Line Breaks/Space Before/After H1 tags
- Free Download Manager for Firefox
- Web Development and Design Tool Recommendations
- .htaccess and WordPress
- Removing Image Borders with CSS
- What does it mean to be pinged
- Graphic Design Tool Resources
- Free Blog Software Recommendation
- How to use cPanel to backup your website










