Jump to content

Valid XHTML Strict!! ARG..!


Recommended Posts

#footer h1 {

margin:0; padding:0; font-size:1em



That will make your heading act as any other generalized text within the id.


<span class=


and <p class =


why shouldn't span be used? Why p instead?


Because <span> is not a tag level block element ... it is a styling element only. And it should only be used when you need to make a styling change within a pre-styled element, that just "spans" a few words.


Like this.

<div id="footer">
<p class="copyright">copyright © 2007 <a href="#">DBrimlow</a> |
    All Rights Reserved | <a href="http://validator.w3.org/check/referer">Valid Xhtml
   </a> | <a href="http://jigsaw.w3.org/css-validator/check/referer">Valid CSS</a></p>
<p>For more information about <span class="redstyle">"Using Span Within a Tag"<span>, just ask Dave.</p>


Now, I did a few things to show you how styling affects the "page weight" of your document.


First. The key to perfect page markup is keeping it lean and clean.

You want your page to load as quickly as possible. Adding and/or repeating code is like a chubby 10 year old eating yet another canoli ... the page bloats proportionately and the needle on the scale rises.


It is tough enough that your graphics will be trying to cram themselves into the users cache as quickly as possible without the markup and the css jamming up the works with bandwidth weight bottle-necks.


The code and css is under your control, help it to sprint ahead and let the graphics ease their bulk into the cache without competition.


SO. Notice my footer.

First, I already have styling for the footer ID.

And, I have styling for my body <p> tags.

So I want to make a special styling in the footer, so I use <p class="copyright"></p> all the class does is alter the padding & background color for one certain paragraph.


Then I go back to the simple <p> tag (because I already have it styled in my css, as well as any font changes within my footer styling).


BUT, I have a short little "span" of words that I want to use a certain class style ( "redstyle") for all such events, whenever they occur on the page ... and have used it a few times, on just  short little "spans" of words within the page.


Hence the name of the element ... SPAN. It is used to span a few words within a pre-styled element.


Damn. I took a long road to say that! LOL.





Link to post
Share on other sites

Alright now I'm getting you guys. I now understand why H1 would be so important, and all the other <H..>'s. but what about this:


<span class=


and <p class =


why shouldn't span be used? Why p instead?


like we said before...


text has to have some kind of meaning, that's why a book has structure. a <p> is a paragraph - a recognized structure in the world of text. A span has NO recognized context that can be applied to it.  Think of the span as the only styling element of html. It allows you an element to change the style of its content without affecting the meaning of all the text in and around it.


As an example I vaguely remember reading somewhere that the <i> tag (and <b> <u> <sup> <sub> etc.) should no longer be used but a span should be used instead; and the style applied to that.  Some will say '<strong>' replaces bold - not true <strong> actually has its use based in screen readers - allowing the change on stress of the word - similarly <em> specifies emphais.


It just so happens that browsers make <strong> bold - which is actually wrong if you just wanted to embolden a word but DIDn't want to alter how it should sound... (OK why make something bold if you didn't want to imply some extra importance and hence extra stress if you were speaking the text out loud)

Link to post
Share on other sites

An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).


This is what I get when trying to valid my xhtml. From what I understand, this means I can't use the same ID twice in a document. My question is, why is this so? I though class and ID where the same darn thing in XHTML!!! Arg!!!

It seems to be explained pretty clearly in the explanation that you quoted.

Is there some reason that you are refusing to use classes?

Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.