NameSilo

XHTML Centering

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

WebmasterTalk.us

Account Closed
Impact
2
Hello,

In XHTML, the only way I can center content and such is using CSS right? Using any align (<p> or <div>) attributes seems to be invalid, and using the <center> tags seems to be invalid, also. :(

The only way I can do this properly is through CSS? :alien:
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
iHosty said:
Hello,

In XHTML, the only way I can center content and such is using CSS right? Using any align (<p> or <div>) attributes seems to be invalid, and using the <center> tags seems to be invalid, also. :(

The only way I can do this properly is through CSS? :alien:

Generally, CSS plays a powerful role in XHTML and try it in that way.
 
0
Close
if you wish to center the entire page just put <div align="center"> right after <body> then put </div> right before </body>.

If you wish to just center stuff, you could apply it using CSS via an external linked file... or you could include it in your header. An alternative is to do this:

<div style="align: center">Content </div>
 
0
Close
hey, I had the same problem for a long time, then I tried using <center></center> and it allowed it. I think <center> is a tag that IS allowed.
 
0
Close
To center the text inside a div:
text-align: center;

To center the div itself:
margin: auto;
 
0
Close
<center> is only invalid in XHTML 1.1. In XHTML 1.0 it's valid. I find XHTML 1.1 to be way to strict if you ask me.
 
0
Close
There are at least two proper ways to center an element using CSS, these include:
Code:
element {
	text-align: center; /* for aligning text */
}
and:
Code:
element {
	margin:0 auto; /* to align anything else */
}
edit: I should mention that transitional XHTML does allow older HTML 4 elements, but I wouldn't recommend using transitional anyway.
 
Last edited:
0
Close
Rowan W, what did I write?
 
0
Close
sorry, must have scanned over it, all those other replies had me going blind.
 
Last edited:
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back