Forum Moderators: mack

Message Too Old, No Replies

How to force <center> tag to pass XHTML Validator

Having trouble with assignment by instructor

         

cmac38

8:43 pm on Jan 24, 2004 (gmt 0)



The instructor says to use the <center> tag to center the sentence on the page. Then we run it through the validator. Of course it kicks out as an error.

Then he says there are two ways to fix it and one way will pass the validator. I can't figure it out. Any help out there?

Thanks.

iamlost

12:37 am on Jan 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld, cmac38!

I suggest that you always do a search on www.w3.org when wondering how to write valid code.

Read the following for your answer:
ht*p://www.w3.org/TR/REC-CSS2/text.html

grahamstewart

3:54 pm on Jan 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<center> is deprecated and has been since HTML4 came out in 1997 (along with pretty much any tag or attribute to do with page layout).

I wonder why your instructor is even mentioning it?
I'd be 'interested' to see what he suggests as the two fixes? I reckon they may not match what the rest of the forum suggests :)

davidpbrown

4:06 pm on Jan 26, 2004 (gmt 0)

10+ Year Member



Seems like a reasonable question.
Simply asking how do you centre text in a way that is valid.. not so much?what is the XHTML center tag.

BlobFisk

4:12 pm on Jan 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use CSS to do this:

<p style="text-align:center">Some Centered Text</p>

Or, use a class:

.centerMe {
text-align:center;
}

<p class="centerMe">Some Centered Text</p>

HTH