I'm making a very simple html webpage consisting only of text. How can I narrow the single column to make it easier for the reader to read?
I would like the body of text to be roughly in the center of the page and left aligned, with margins of white space (roughly equal) to left and right.
By putting the text inside a DIV with a style to control the width:
<DIV style="width: 300px">
Text goes here.
</DIV>
For centering, based on Angela's suggestion in the comments:
<DIV style="width: 300px; margin: 0 auto">
Text goes here.<br>
And another line which is much longer.
</DIV>
The html:
<div id="centered"><!-- put your content here --></div>
The CSS:
body {
text-align:center; /* this is required for old versions of IE */
}
#centered {
width:400px; /* this is the width of the center column (px, em or %) */
text-align:left; /*resets the text alignment back to left */
margin:0 auto; /* auto centers the div in standards complaint browsers */
}
That's it, enjoy!
Using CSS...
body {
margin:0 auto;
width:600px;
}
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