Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering an <hr> tag

Tags:

I'm having some trouble with my hr tag in HTML, as it isn't automatically centering as I expect it to. This is what my current code looks like:

<div id = "updatestatus" class = "statuscontainer">     <div class = "verticalalign">Update Status</div> </div> <hr width = "95%">  <div id = "insertstatus" class = "statuscontainer">     <form></form> </div> 

As you can see, I'm placing my hr tag in between two divs, and I believe it's supposed to automatically center, but it ends up going to the left instead. I have also tried hr align = center with no success either.

Edit: I just realized that when I place the entire hr tag within <center></center> it centers, but I'm still trying to figure out why it doesn't center on its own.

like image 447
Phil Avatar asked Jul 15 '14 03:07

Phil


People also ask

How do I center my tagged photos?

An <img> element is an inline element (display value of inline-block ). It can be easily centered by adding the text-align: center; CSS property to the parent element that contains it. To center an image using text-align: center; you must place the <img> inside of a block-level element such as a div .

How do I center my h1 tag in the middle of the screen?

In this example, we have an <h1> which is placed on the upper left hand side of the page. If we wanted to horizontally center that text on the page, then we can use the text-align property. If you wanted to horizontally center all of the text on the page, then you can use the text-align property in the body selector.

What is HR align in HTML?

The align attribute is used to set an alignment for the <hr /> tag. It takes left , center and right values. The default is left – meaning if an alignment is not set, the <hr /> tag automatically aligns to the left. <hr width="50%" color="green" size="50px" align="right" />


1 Answers

Try margin: auto;

<hr style="width:100px; margin: auto;" /> 
like image 127
Gaurav Avatar answered Nov 07 '22 08:11

Gaurav