I want my <p> element to be at the center of a container <div>, as in perfectly centered -- the top, bottom, left and right margins split the spaces equally.
How can I achieve that?
div {
  width: 300px;
  height: 100px;
}
p {
  position: absolute;
  top: auto;
}<div>
  <p>I want this paragraph to be at the center, but it's not.</p>
</div> 
     
    
 
     
     
     
     
     
     
     
     
     
    
tag. If you did, you could do something like this in your stylesheet: p { width: 200px; height: 10px; position: relative; top: 50%; left: 50%; margin: -100px 0 0 -5px; }
– Spencer Cameron-Morin Feb 27 '13 at 20:14