For a free RSS subscription, click here.

Learn more.

Enter your email address to receive Netregistry News in your inbox:

Delivered by FeedBurner



Advanced Search
CSS Controlled Web Design
By Netregistry News | Website Development | Rating:
Page 1 of 1

Tables are for sitting at...

by Sasch Mayer

By now, most web designers are aware of the many benefits of using CSS (Cascading Style Sheets) to control the formatting and appearance of text elements within their web pages. Indeed Cascading Style Sheets can substantially cut down the amount of code needed to present a web page in a polished and professional manner. What few designers realise however, is that CSS is capable of so much more than just handling a page's text formatting.

If used to its fullest capability, the Style Sheet is capable of controlling just about every aspect of page layout and presentation, even to the extent of replacing a Hyper-Text document's traditional table-based design structure. Quite aside from saving the web developer a substantial amount of coding time, this approach also cuts down the amount of code needed to display a web page properly to an absolute minimum. So much so that in the recent redesign of one of our web sites, the use of CSS controlled HTML cut the average document size from 24kb to less than 5kb.

The key to designing CSS controlled web pages, rests in the use of DIV Tags and DIV IDs.

For example, a traditional table structure would look something like this:

<table width="800" align="center" cellpadding="0" cellspacing="0">
  <tr>
  <td width="560" align="left" class="one"><h1>Example Text</h1></td>
  <td width="240" align="left" class="two"> <img realsrc="images/exampleimage.jpg" src="http://netregistry.com.au/news/admin/images/exampleimage.jpg" width="200" height="100" alt="Example Image"></td>
  </tr>
  </table>

With CSS control, exactly the same look and feel can be achieved by the following two DIV Tags:

<div id="content"><h1>Example Text</h1></div>
  <div id="image"><img realsrc="images/exampleimage.jpg" src="http://netregistry.com.au/news/admin/images/exampleimage.jpg" width="200" height="100" alt="Example Image"></div>

The DIV ID passes control of layout and appearance to the CSS, which handles it as follows:

#content {
      position:absolute;
      width: 560px;
      height: 100px;
      ;top: 10px;
      left: 100px;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 12px;
      font-weight: normal;
      color: #000000;
      background-color: #FFFFFF;
  }
#image {
     position:absolute;
     width: 240px;
     height: 100px;
     top: 10px;
     left: 660px;
     font-family: Arial, Helvetica, sans-serif;
     font-size: 12px;
     font-weight: normal;
     color: #000000;
     background-color: #FFFFFF;
  }

On the face of it, it may seem like this entails some extra work on the designer's part, but don't forget that at the same time as controlling the DIV Tag's position and appearance, the CSS also handles all text formatting, and that the above Style Sheet will only need to be written once in order to control an entire web site. Then of course there is the fact that the above example is an immensely simple one. Imagine for a moment, the sheer amount of code which is saved by using CSS over the course of writing an in-depth web page.

The end result is an HTML document which has been stripped of all unnecessary code and is consequently extremely 'light-weight' and easily indexed by search engines. Additionally, it is also possible to radically alter a page's appearance at the click of a button without ever changing any of its HTML code. This approach is very capably demonstrated at the CSS Zen Garden, where more information about the power of CSS controlled web design can be found.

Furthermore, like HTML, CSS is undergoing constant revisions and will doubtlessly grow to play an even more important part in web design during years to come. Therefore, now may be a good time to further acquaint yourself with the full functionality of this essential web design element.

About the Author

With well over a decade of industry experience, Sasch Mayer has been writing about the World Wide Web and Internet Marketing for many years. He currently writes under contract to IceGiant Web Services, a company specialising in high-quality Web Design using both the traditional table-based and also the CSS controlled methods. Visit the IceGiant Web Site for more information.


Share and Enjoy:

StumbleUpon Toolbar


How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Your NameYour Email
Your Comment:

Verification:
Enter the security code shown below:
imgRegenerate Image


Comments
  • Comment #1 (Posted by ben)
    Rating
    word, im with you all the way. i was reading an article on this site 6 months ago about how it is fine to use tables for everything because its easier and quicker and i shook my head in shame.

    aside from the semantics, the trend of professional web design and all the other geeky arguements, it really is quicker, easier and more logical to use css and tableless layout markup. the only downside is that you have to invest some time in learning how to do it.

    if your at a crossroads on the subject i say make the jump, yes its a whole heap of hours to learn how to do it properly, but thats education. i spent a year umming and arring then one day just sat down and learnt how to do it and since i invested the time i havent looked back. plus i got a better job out of it.
     
  • Comment #2 (Posted by Drew Wall)
    Rating
    This is a comment on Ben's comment.
    I hope Ben invests more time in his CSS HTML language structure and syntax rulles than he does in the syntax of English. If he was that lazy with his programming he would not produce a result. Why is it though by the X Y generation that correct written expression has no value in conveying a message.
     
  • Comment #3 (Posted by peter)
    Rating
    For someone who constantly looking for new idea, this article is very pedestrian compares to many other articles out there on this concept. First, it merely shows an alternative on how to convert a simple table to a simple structured layout. At the very least, it should have some in-dept information on the powerful design using xhtml + CSS. Unfortunately, after skimming this article, I found nothing remotely useful.
     
  • Comment #4 (Posted by Michael McCorry)
    Rating
    In response to Drew, you haven't been on the Internet very long have you? He wasn't writing an essay, he was posting a quick reply to a blog. Was there something about his post you didn't understand? Didn't think so. Do you use full spelling, grammar and punctuation checking when sending SMS text messages? Also as an aside, some of the best programmers I know are horrendous spellers.
     
  • Comment #5 (Posted by Craig)
    Rating
    Re Michael's comment: I agree that spelling is less important in a forum context, however an ability to spell is something I value highly in a programmer, in addition to their coding and programming ability. The last thing I want to do is 'sweep up' a lot of spelling mistakes that affect important SEO info, links and body copy. They reflect on the overall professional appearance of a site, to the public and to our clients.
     
  • Comment #6 (Posted by Wayne)
    Rating
    Message to Drew - if Ben's correct use of english was important to you, you should have paid more attention to you own comment. Would have had more impact without the spelling mistakes and faulty grammer......
    As for the article, great article and yes it is time web designers moved on from tables. It makes maintenance more difficult for those that have....
     
  • Comment #7 (Posted by JimmyShakes)
    Rating
    I thought this article hit the spot with me. It just confirmed that I was heading down the right track with maximising my use of CSS. Gee Peter, you like blowing your own trumpet mate... ohh your so smart... oh your better than everyone else.
     
Submit Comment