Emerald214 Emerald214 - 16 days ago 5
CSS Question

Horizontal line throughout HTML page

I like to put a line throughout HTML page. How to do this?

enter image description here

I tried:

hr {
width: 100%;
}


but it doesn't work

Answer

The <hr /> tag is always of 100% width of its parent tag.

<br />​<hr />​​​​​​​​​​​​​​​​​​​<br />​​​​​

Check if the parent has some padding which you need to remove. Another option is to set the body tag's padding and margin to 0.

body {
 padding: 0;
 margin: 0;
}

Complete code:

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            body {
                padding: 0;
                margin: 0;
            } 
        </style>
    </head>

    <body>
        <br />
        <hr />
        <br />
    </body>
</html>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​