Yes, its really easy to add class names as you need them and there is a level where it seems both logical and usefuul.

Sadly that is not the reality though. Patrick hit the nail in the head when he mentioned changing designs and having that once relevant class name end up attaching styles that no longer match the name you originally chose.

Adding a class name of "centre" is just as bad as picking something like "red". If you take a step back when preparing to apply classes to things, you'll find that you are always thinking "all the links in the nav section" or something to that effect, hence using the single class or id on the parent element and selectors to achieve what you want.

To climb down fro the soapbox and into a working reality you have to break these rules sometimes. Every page I've ever made that uses any floats has somewhere a:

<div class="clear"></div>

with matching css:

div.clear {
   clear: both;
   }

I could come up with fancy workarounds but in the midst of deadlines I'll add one superfluous element anytime.

Same thing with my navigations:

I always:

<ul>
   <li><a href="#">Link Text<span></span></a></li>
</ul>

Yes, the extra span shouldn't be there. Having it there always me to perform elegant image replacements and degrades gracefully. The mere site of that HTML may send some of our members to instantly flame that practice.....

The bottom line is that there is a pleasant middle ground that exists between perfect standards compliance and accomplishing what you want. Like anything else you should only break the rules if you know the rules - just in case....

Joseph R. B. Taylor
/Designer / Developer/
--------------------------------------
Sites by Joe, LLC
/"Clean, Simple and Elegant Web Design"/
Phone: (609) 335-3076
Fax: (866) 301-8045
Web: http://sitesbyjoe.com
Email: [EMAIL PROTECTED]



IceKat wrote:
How is using a name which is descriptive and easy to remember and understand (like for those coming in after you've written the code) going against that separation? It's not actually putting the styling in the html and if anything it saves coding. If you have a class of center then you can define it in your stylesheet as
.center{
   text-align: center
}
and anything has that attribute, including divs, headings, paragraphs etc. Imagine creating and writing a class for everything like that which needs it! You'd wind up with 50 extra lines of code and a bigger file and therefore longer download time.

Plus if it's a class then you don't have to worry about it being used more than once on a page and you know exactly which name to use when you need that attribute as will anyone else who comes across it later.

IceKat


Joseph Taylor wrote:
FYI - Adding such a named class, especially with the name "center" or "center" goes against separation of presentation and content.

In a situation where your HTML looks like:

<div>
<div class="centre">
<my images />
</div>
<div class="centre">
<my images />
</div>
<div class="centre">
<my images />
</div>
</div>

You should change it to something like:

<div id="my_section">
<div>
<my images />
</div>
<div>
<my images />
</div>
<div>
<my images />
</div>
</div>


Then your CSS rule could look more like:

#my_section div {
text-align: center;
margin: 5px;
}

One day you'll wish that div didn't have the class name of center, especially if there are a bunch of them. Just give an id to the container that would hold them all and use your css selectors to isolate the elements you wish to style.

In the end, either choice will create the same effect. This one is a little more "future proof".

Joseph R. B. Taylor
/Designer / Developer/
--------------------------------------
Sites by Joe, LLC
/"Clean, Simple and Elegant Web Design"/
Phone: (609) 335-3076
Fax: (866) 301-8045
Web: http://sitesbyjoe.com
Email: [EMAIL PROTECTED]



Stuart Foulstone wrote:
Or use a CSS class to do the same,

<div class=”centre” >

and

.centre {
      text-align: center;
}

On Sat, May 3, 2008 10:22 am, Diego La Monica wrote:
What about <div style=”text-align: center”> ?





Diego La Monica

Web 2.0 - Standards - Accessibilità

mobile: +39 3337235382 - skype: diego.la.monica

web: http://diegolamonica.info - http://jastegg.it



  _____

Da: Simon [mailto:[EMAIL PROTECTED]
Inviato: sabato 3 maggio 2008 11.15
A: [email protected]
Oggetto: [WSG] Alternative to align = center?



Hi,



I know that the align attribute such as <div align=”center”> is not
allowed
in XHTML Strict, but it got me thinking on what the possible alternatives
are for a dynamic environment such as a forum?



For instance if I know the image width or the total width of all the
images
will be the same I usually put them in a wrapper with a fixed width and
use
margin: 5px auto as an example.



What happens if you will never know the width of the images or how many
images someone may post, as happens on a forum I run. I’ve resorted to
creating a bbcode tag that uses <div align=”center”> as that is the only
way
I can think of.



Are these scenarios always doomed to use transitional doctypes and
deprecated code?



I’d be interested in your opinions



Cheers

Simon


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************





*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************



*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************



*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************
begin:vcard
fn:Joseph Taylor
n:Taylor;Joseph
org:Sites by Joe, LLC
adr:;;408 Route 47 South;Cape May Court House;NJ;08210;USA
email;internet:[EMAIL PROTECTED]
title:Designer / Developer
tel;work:609-335-3076
tel;fax:886-301-8045
tel;home:609-886-9660
tel;cell:609-335-3076
x-mozilla-html:TRUE
url:http://sitesbyjoe.com
version:2.1
end:vcard


Reply via email to