James_Parsons Posted January 10, 2013 Share Posted January 10, 2013 (edited) I know the tag is deprecated but is there an easy way to center items. for example take this code and "de-deprecate" <!DOCTYPE html><html><body> <center><p>Hello</p></center></body></html> Edited January 10, 2013 by James_Parsons Link to comment Share on other sites More sharing options...
niche Posted January 10, 2013 Share Posted January 10, 2013 http://css-tricks.com/snippets/css/centering-a-website/ Link to comment Share on other sites More sharing options...
DarkxPunk Posted January 10, 2013 Share Posted January 10, 2013 create a class such as .textCenter {text-align: center;} then wrap the <p> in a <div> and give the div that class. <div class="textCenter"><p>Hello</p></div> Now with that all you have done is centered the <p> inside the <div>, not the document so now we need to center the div. .divCenter {margin: 0 auto;} Now apply it to the div. <div class="divCenter textCenter"><p>Hello</p></div> All done. Now it may seem like allot, but once you add allot more content you will see how convenient this is. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now