First for mac news, reviews and know-how
  
Welcome Guest  Register Log in
  Advanced 

Features


Smarter sites with style sheets

8th November 2004 [MacUser]
Find out how to cut your coding time and make more attractive sites that will work in every browser, every time.

CSS stands for Cascading Style Sheets, and understanding the cascade is essential when building a modern website. Although modern browsers will still render hand-coded font and table tags, this practice is now frowned upon from an accessibility and speed point of view. Because HTML and XHTML enable you to attach multiple style sheets to a web page, which may also have embedded style sheets and inline styles, multiple rules can affect the same element, which potentially leads to conflicts. The cascade order is a set of rules that resolves such conflicts.

In this masterclass, we will build a website using style sheets to define the layout, as well as the styling of the text and images themselves. However, because some of our content will be positioned inside a shaded box, while the rest will be on the plain white background of the standard page, not all of our default stylings will work. We will therefore tweak our style sheets to recognise not only the content, but also where it is positioned, so that it can apply a different set of styles to content inside the box from the content on the plain page.

You could, of course, define entirely new styles for each element of your page that takes into account its positioning, so set up one style for text on the plain background, and another for text that has been shifted to the right and positioned within a box. But this would mean manually applying the style to each element.

Putting in additional styling definitions
 
 
ADVERTISEMENT
to each of our style sheet entries that are determined by the container in which they are held, as we do in Steps 9 and 10, means we can re-use the basic elements of each one, and they will be inherited by the reworked styles in our navigation box.

W3C site validation

Although print designers do not think twice about using various pieces of software to ensure their work is fine before it is sent to the printers, web designers rarely do the same before uploading it. As soon as someone mentions validating web pages, some designers get all snooty, stating that they prefer to stick to the important stuff - the visual design - and ignore the elements they consider geeky. However, validation is an essential part of creating a website. If pages validate, they are more likely to work accurately across a range of browsers. What's more, proprietary elements will not be included, and they are more likely to be future proof, thereby breaking the build/break/rebuild cycle when new browsers are released.

The W3C website at www.w3.org provides a number of useful tools for checking your web pages. The CSS validator (jigsaw.w3.org/css-validator) enables you to test online or offline files, and it flags errors (which must be fixed to create a valid document) and lists warnings (suggestions that tend to improve your CSS). The mark-up validation service (validator.w3.org) works in a similar way, often flagging errors in the code that would lead to your site not working in the way you intended. The W3C suite also contains a link checker, which checks whether links are intact and that they are accessible to those with disabilities.

Some web design applications have similar tools, but we recommend you use the W3C services for your style sheets and main web page templates, as applications rapidly age and the online services are kept up to date in terms of the latest standards.

Continued....

Read comments: 0
1 | 2 | 3 Next page
Related News
Related Reviews


MAC GUIDE

The Independent Guide to the Mac 2

Featuring all the essential tips, crafty techniques and information you need, this fully updated publication is the definitive guide to the Apple range and a must have for any switched on individual.
If you would prefer a digital version for only £5,  click here

IPOD GUIDE

The Ultimate iPod Guide

Hundreds of tips to make the most of your iPod - covering every iPod, old and new.

IPHONE GUIDE

The Independent Guide to the iPhone

Master the iPhone, tool by tool. Everything you need to know about the most remarkable portable gadget.

GRAPHIC GUIDE

The Ultimate Guide To Graphic

Covering Photoshop, InDesign, QuarkXPress and more, this comprehensive guide compiled by experts across the field of computing, presents the reader with the vital knowledge of how to harness the power of their computer and use this to create professional, appealing and engaging projects.