Saturday, April 09, 2005

Planning Structural HTML

It's great to see such a straightforward explanation of how one might think about structuring an HTML page with CSS in mind as this: The Early Bird Catches the CSS: Planning Structural HTML. One criticism -- whilst <div> elements are probably very useful for beginners to separate the structure of the site and as hooks for descendant selectors, I can't think of many reasons why the navigation <ul> elements need individual <div> containers. It's simpler and leaner to give the <ul>'s an ID and the advantages mentioned:

The nesting of div elements, as in this example, allows you more options for CSS rules to present what is structurally just two lists. There could be a presentation rule for #navcontainer, and another for #globalnav?For example, the #navcontainer rule might center the div in a column, while the #globalnav rule might left align the text of the centered div. And, of course, there can be rules for the presentation of #globalnav ul or #globalnav li that use this structural context. The rules for the list in #subnav could be completely different in terms of presentation.

can be achieved equally well with ID's on the <ul>'s. Are there any other reasons for the <div>'s? (Hackery to make IE work?)

No comments: