Jump to content
Sign in to follow this  
James_Parsons

Centering

Recommended Posts

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 by James_Parsons

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...