Home arrow HTML arrow Page 3 - CSS: Where Little Things Mean a Lot
HTML

CSS: Where Little Things Mean a Lot


You’ve heard of people talking about having a site made using CSS, otherwise known as Cascading Style Sheets. So you decide to have a look at this CSS stuff only to discover that it makes no sense. How can somebody make a site out of this? Well, to put it bluntly, they don’t make a site with CSS; rather they make the site just as they would any other site, using good old HTML and link their page(s) to a CSS file. This file holds all the information on how the page will look; from what color the background is, to what font the body of the site will use.

Author Info:
By: Christopher Duell
Rating: 3 stars3 stars3 stars3 stars3 stars / 28
March 29, 2004
TABLE OF CONTENTS:
  1. · CSS: Where Little Things Mean a Lot
  2. · On to CSS
  3. · CSS and the DIV Tag

print this article
SEARCH DEVARTICLES

CSS: Where Little Things Mean a Lot - CSS and the DIV Tag
(Page 3 of 3 )

OK, so you’re convinced now right?  I’m sure you’d like to know just how powerful this file really is. Here is the answer:

Almost everything can be controlled by this file including (to an extent) the overall layout of your site.  Some sites, like Wired.com, have created their entire site with the use of CSS to control their layout. As you will see, they’ve employed a fairly complex layout--all through the use of CSS!

I will let you in on a secret though, they make extensive use of the <div> tag. This is a block level element, meaning that it will live on it’s own line unless told otherwise, in much the same way that a <blockquote> tag will be on its own line, and not ‘inline’ with anything else.  In each <div> tag you can set what ‘class’ (or type) of section of the site it will hold, for example you could change the HTML file to have:

<div class=”title”Examples 'R' Us</div>

Viewing this will be no different to what it was before, unless we change the CSS file accordingly to alter the settings for this class, for example:


div.title{
width
:100%;
height
:25px;
background
#FF0000;
border-style: solid;
border-color: #FFFFFF;
border-width: 2px;
}

Now looking at the web page, it has changed again to represent the changes made to the CSS file. To see some of the other features of CSS displayed download the support file for this article (available here).  By having a look at the accompanying files, you will see that two extra <div> tags were added; one named ‘side’ and another named ‘main’.  Each has their own different style which is controlled entirely by the Style Sheet (CSS file).

Looking at the Style Sheet attached to the support file, you will also notice that the ‘a’ (anchor) tag has also had an overhaul.  Instead of having the default blue-colored underlined links, the code in the Style Sheet now tells the browser to display links in red, with no underline.  When the mouse goes over the link, they change to blue, with an underline and overline to catch the viewer’s attention.  A few other changes have been made to the original Style Sheet that we created earlier, but nothing that you shouldn’t be able to spot.

Your next step is to check out a site that lists all the elements that you can play with using CSS and what you can do with each element.  This article was only a tip of the CSS iceberg. The powers of CSS are too huge to contain in one article, so I would suggest that you purchase a book on CSS, as you will find yourself looking it up time after time to get your site to look just the way you want.

Happy coding!


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
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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