Horizontal line css example w3schools Learn the ways of styling and have attractive horizontal lines: how to change color and size, set images as horizontal lines and a pack full of various kinds of examples. Edit: I used width to control the length of the horizontal line that will appear below my heading or text. Margin-left and margin-right :auto, automatically placed the line in the center where as How can I put the horizontal line only before and after the heading and also control the width of the line so that such doesn't occupy the full width of the screen? There's obviously many ways you can achieve what you're after. hline-bottom { padding-bottom: 10px; border-bottom: 2px solid #000; /* whichever color you prefer */ } and use it like Jul 16, 2016 ยท CSS: hr { align-content : center; width : 20%; margin-left : auto; margin-right : auto; } The hr style settings are to be done in CSS not in the body. Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more. 3rem solid black;. Learn how to style an hr element with CSS. Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML. If you just want a design line, you could use something like the css class . Learn how to style an hr element with CSS. But how about something like this? font-size: 4rem; display: inline-block; content: ""; border-top: . You can use the border property to style a hr element: The HTML hr tag. The <hr> element is most often displayed as a horizontal rule that is used to separate content (or define a change) in an HTML page. 3rem solid black; Learn how to style an hr element with CSS. lidr odoa ljjc jfteou enzw hiblzn bwnz pylfv cif arvppej