Home arrow Style Sheets arrow Page 5 - 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 - Doing It In Style
(Page 5 of 5 )

One of my great joys in life is getting a song stuck in someone's puny mind, and now, thanks to the great wonders of modern technology, I can do so on a mass scale: we're talking the literally tens of people that will read this article. So behold: every time I think of style sheets I get that eighties song "Puttin' on the Ritz" stuck in my head. Dressed up like a million dolla trooper...trying hard to look like Gary Coopa...supa-dupa.

There are three ways to insert a style sheet. They are as follows:

Externally Yours

If you want to apply a style sheet across multiple pages, you can do so with an external style sheet. Every page must have a link to the style sheet. When you change a part of your style sheet, it changes every page linked to it. For instance, if you initially set all your headers to have red text, and then changed the sheet so that they have black text, all the pages will then be updated so that their headers have black text instead. That's much easier than you having to go and change all of the text one by one.

We use the <link> tag to to point to the style sheet. Note that the link tag is inserted in the head section:


<head>

<link rel=”stylesheet” type=”text/css”

href=”somestyle.css” />

</head>

When the browser sees the link, it goes out to your style sheet, reads it, and applies it to your page.

Internal Affairs

If you want to apply a style to a single page, you are better off using the Internal Style sheet. In this method, you define the styles in the header section of the document, and not in a text editor file (unless you are writing your HTML in the text editor of course). Here is an example:


<head>

<style type=”text/css”>

p {color:blue;font-family:Ariel}

h1 {text-align:center}

</style>

</head>

This will apply the style to every <p> and <h1> in your page.

Inline Style Sheets

You use Inline Style Sheets when you only wish to change a single occurrence of an element, like so:


<h1 style=”color:red;text-align:right”>LOOK I AM A HEADER!</h1>

Well that's it for this tutorial. Be sure to come back next time when we really dig our hands in and begin to do real work with CSS.

Till then...


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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 1 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials