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 div
s, 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.
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 .
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.
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" />
Try margin: auto;
<hr style="width:100px; margin: auto;" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With