Website Design Edmonton       Website Design Feedback       Website Design Sitemap     Contact Website Design Company
Website Designers R Us - Home
CSS and the DIV Tag

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!

Return to Listing

Website Designer R Us has over 12 years of IT experience and a focus on custom website design, web development and web hosting services. Our professional web design services will give your business the look and feel needed to beat your competitors! Our website design services include; web design, website redesign, website maintenance, web development, flash animation, eCommerce, shopping carts, domains, web hosting, search engine optimization, graphic design, logo design, blog writing, script installations & much more!
 Home          ::             About Us          ::             Support            ::             Services            ::             Link Partners          ::             Contact

Copyright © 2006-2011 Website Designers R Us, a DOT Specialist Company. All rights reserved.