Jump to content

How to use Center align instead of to use center tag


juanrojo1987

Recommended Posts

Hi everybody!
I'm trying to solve a problem with my css and html code in my site peliculas online.
When I analyze this site in the w3c validator (http://validator.w3.org/) it shows a bad use of the tag <center></center> and I really don't know how to fix that.
Could someone help me with this? Perhaps you know about another way to center the content. I had just tried with text-align:center; and margin: 0px auto; but nothing good appear.
  1. error.png Line 183, Column 8: The center element is obsolete. Use CSS instead.
    <center><div id="wrapperall">

  2. error.png Line 563, Column 8: The center element is obsolete. Use CSS instead.
    <center><div id="container">

Thanks a lot!
Link to comment
Share on other sites

If it's a block element, like <div>, give it a specified width and then set the left and right margins to "auto".

 

It it's text, or an inline element, then set text-align to center on the parent element.

Link to comment
Share on other sites

In regards to <center><div id="container">

If you are trying to center the div itself, specify a width AND auto margins for the left and right. (the width can be pixels, ems, or percentage)

 

#container {width:90%; margin:0 auto;}

 

 

If you need to center content within a particular div, then you would use text-align:center as follows:

 

#container {text-align:center;}

 

 

Or............. let's say you would like to center the contents of a paragraph using an inline style....

 

HTML: <p style="text-align:center;">Content here. </p>

 

 

Or, create a class on your external style sheet called "center" as follows....

 

.class {text-align:center;}

 

Then apply this class to the element you want to center the content, such as a paragraph....

 

<p class="center">Content here.</p>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...