davesite.com / webstation / css

Cascading Style Sheets: An Interactive Tutorial for Beginners

Cascading Style Sheets: an Interactive Tutorial

Basics of using CSS

part 3

advertisement

advertisement
#1 Web Hosting Plan! Free Software & Tools!
1000GB space, 1000GB bandwidth, just $6.95!

@import can be used in conjunction with the other methods. Imagine you want 2 pages out of your initial 10 pages to have, in addition to the normal indent, each and every paragraph in blue text. You could write a second style sheet, we'll call it coolblue.css, and inside that sheet you have:

p { color: blue; }

Then, in those 2 special pages, you place the normal CSS link, but you'll add special code, @import, to add the extra color.

<link rel="stylesheet" type="text/css" href="main.css" title="Default">
<style type="text/css">
<!--
@import url(coolblue.css);
--></style>

With the import code, you can mix additional styles with a regular style sheet, without affecting the other sheets. So 2 pages now have blue paragraph text, while the remaining 8 pages do not.

Those are the basics. Let's review the ways you can include a style sheet:

  • Write it inline inside each and every tag
  • Place a <style> </style> at the beginning of the web page
  • Dedicate and link a CSS file and write it inside that file
  • use @import to include it as portion of a page's CSS

In this interactive tutorial, you can use either inline or <style> </style> to test out style sheets. (Imagine 100 people working on a main.css on our server at the same time? Who would win?)

I highly recommend that you use the link (and if needed, import) method to develop style sheets for your own web site after you finish our guide.

Ready to test your skills? Use <style> to make all paragraphs have 10 spaces indentation (hint: 6em) and make the text red. Hint: Combine both into one line of code using the ; separator. Remember to create a paragraph in the <body> to see the style in action!

Click here for an answer if you get stuck or you want to see how I did it.

advertisement

WIN A NEW CAR! Yahoo! Web Hosting

< Ch. 2 part 2 > Chapter 3




Learn about the #1 Ranked Web Host. 100 GB Space.
Up to 7 Web Sites. Free Domain & Setup. Click Here.

Copyright © 2002 Dave Kristula. All Rights Reserved.

davesite.com