I suppose it wouldn't matter if you used a class or id, but the id can
be linked to from within the document, so if your page had a table of
contents or something, you could jump from point to point.
Id's have to be unique on the page, so they are perfect for attaching to
the unique sections of the document, so you could structure a document like:
<div id="header">
<div id="logo" />
<div id="nav" />
</div>
<div id="content" />
<div id="main_content" />
<div id="sub_content" />
</div>
<div id="footer" />
This makes css more specific. I can easily say make all text in my main
content 100%, but sub content should be smaller and lighter lets say:
#main_content {
font-size: 100%;
color: #000;
}
#sub_content {
font-size: 80%;
color: #666;
}
Or you could get really specific, lets say the only links on the page
that wouldn't be underlined would be links within unordered list items
that are nested within other list items, and only in the subcontent section:
#subcontent ul li ul li a {
text-decoration: none;
}
Any other links in lists would be left alone. This specificity with no
extra classes - all thanks to one id set on a parent element.
As far separation, the less classes etc you have in your document the
better I say since the raw document needs none. As soon as you add
classes etc you begin to intertwine the two. Obviously its a huge
improvement from tag soup even with a bunch of classes all over the place.
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]
Michael Horowitz wrote:
Can you explain to me a little bit more of the theory of why you
would want to use and id vs a class called center is this type of
situation.
Trying to understand more how this becomes an issue of separating
presentation and content.
Thanks
Michael Horowitz
Your Computer Consultant
http://yourcomputerconsultant.com
561-394-9079
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: wsg@webstandardsgroup.org
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