Summary
Line length is the length of a single line of text within a given text area. Line length can be measured in characters, in pixels, or in any other reasonable unit of length. For most webpages, the line length should be between 45 characters and 80 characters, inclusive. Text areas containing small amounts of text (e.g., captions, footnotes, etc.) may have line lengths outside of this range, but most other text areas should not. If the line length is excessive, users may struggle to keep track of their reading position within the text. If the line length is insufficient, the webpage may become very long, making remembering the webpage's textual contents more difficult. Ideally, the line length should be long enough to accommodate the amount of text to be displayed, but not so long that users struggle to keep track of their reading position.
Solution
One easy method of setting the line length of a text area using HTML and CSS is the following:
- In the HTML document that you'd like to change, add a
<div>element. - Within the
<div>element, add a<p>element. - In the connected CSS stylesheet, add a rule containing a declaration setting the
paddingof the<div>element to a positive value of your choice. - Add a rule containing declarations setting the
paddingof the<p>element to0and thewidthof the<p>element to a value between45chand80ch, inclusive. - If the
background-colorof the<p>element is different than that of the containing<div>element, add an additional declaration to each corresponding rule, setting thebackground-colorto the same value for both elements.