Home arrow Style Sheets arrow Page 2 - CSS for the Newbie
STYLE SHEETS

CSS for the Newbie


Although style sheets have technically been around in one form or another since the 1970s, it wasn't until around 1996 that they truly became an official part of the web. And although they had a rocky start with browser support, today they are widely used and offer designers a simple way to define style rules for their web pages, saving them from having to type in colors, fonts, and other layout properties over and over again.

Author Info:
By: James Payne
Rating: 5 stars5 stars5 stars5 stars5 stars / 6
February 25, 2008
TABLE OF CONTENTS:
  1. · CSS for the Newbie
  2. · Putting it all Together
  3. · Selectors...Unite!
  4. · Applying a Style to an Element with an Attribute
  5. · Doing It In Style

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
CSS for the Newbie - Putting it all Together
(Page 2 of 5 )

So now that we know the basic syntax of CSS, let's fool around with it some. Open up a text editor and let's get busy.

Note: Remember that a CSS file is made in a text editor and contains no HTML whatsoever. Also, you must save the file with the .css extention.

Say we want to create a style sheet so that every time the user uses a <p> tag, it automatically changes the attributes of the text within. Here is how we would do it:


p {font-family:verdana;text-align:left;color:blue}

You will note in the above code that we do not place the angle brackets (<>) around our tag. And as I said above, every property is separated by a colon (:). If you wish to change more than one property, then you separate them with the semi-colon (;).

The above code is a little hard to read, and as you can imagine, it would be even harder on the eyes if we were defining an entire style sheet. A better way to write the code would be like this:


p

{

font-family: Verdana;

color: blue;

text-align: left;

}

Note that if we had used a value that consisted of more than one word, like a font name such as Times New Roman, we would encase it in quotes, like so: “Times New Roman”.


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials