Text Formatting Best Practices for Web Content in 2025
Good text formatting improves readability, engagement, and accessibility. Learn the best practices for formatting web content in 2025.
Why Text Formatting Matters
On the web, formatting isn't just aesthetics—it directly impacts:
- Readability: Can users easily consume your content?
- Accessibility: Can all users access your content?
- Engagement: Do users stay and read?
- SEO: Do search engines understand your structure?
Typography Fundamentals
Font Selection
For Body Text:
- Sans-serif fonts for screens (Arial, Open Sans, Roboto)
- 16px minimum size (browser default)
- System fonts for fast loading
- Can be serif or sans-serif
- Should contrast with body text
- 1.25-1.5 times larger than body
/* System font stack */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, Helvetica, Arial, sans-serif;
}
/* Heading with fallbacks */
h1, h2, h3 {
font-family: "Playfair Display", Georgia, serif;
}Line Height (Leading)
Optimal line height improves readability:
| Text Size | Line Height |
|---|---|
| 14-16px | 1.5-1.6 |
| 18-20px | 1.4-1.5 |
| 24px+ | 1.3-1.4 |
body {
line-height: 1.6; /* 160% of font size */
}
h1 {
line-height: 1.2; /* Tighter for large text */
}Line Length
Optimal line length is 50-75 characters per line:
article {
max-width: 70ch; /* About 70 characters */
margin: 0 auto;
}Too wide = eyes tire tracking across the page Too narrow = too many line breaks disrupt reading
Paragraph Formatting
Length
- Web paragraphs should be shorter than print
- Aim for 2-4 sentences per paragraph
- Single-sentence paragraphs are acceptable for emphasis
Spacing
p {
margin-bottom: 1.5em; /* Space between paragraphs */
}
/* Don't indent first line on web - use space instead */
p + p {
text-indent: 0;
margin-top: 1em;
}Alignment
- Left-aligned (ragged right): Best for most web content
- Justified: Can create awkward spacing; use carefully
- Centered: Only for short text (headings, CTAs)
- Right-aligned: Rare; mainly for design purposes
Heading Hierarchy
Proper Structure
<h1>Page Title (one per page)</h1>
<h2>Major Section</h2>
<h3>Subsection</h3>
<h3>Another Subsection</h3>
<h2>Another Major Section</h2>
<h3>Subsection</h3>
<h4>Sub-subsection</h4>Rules:
- One H1 per page
- Don't skip levels (H1 → H3)
- Headings should describe content below them
- Use for structure, not just styling
Visual Hierarchy
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }Emphasis and Highlighting
Bold vs. Italic
Bold ():
- Important information
- Key terms on first use
- Scanning points
):
- Titles of works
- Foreign phrases
- Subtle emphasis
- Technical terms
Don't Overuse
❌ Bad:
**Everything** seems *important* when **too much** is *emphasized*.
✅ Good:
Emphasis works best when used **sparingly** for truly important points.Alternative Emphasis
- ALL CAPS: Avoid (reads as shouting)
- Underline: Reserved for links
- Color: Use carefully (accessibility)
- Background highlight: Good for code or key phrases
Lists
When to Use Lists
- Steps in a process (ordered)
- Features or options (unordered)
- Requirements or criteria
- Any set of 3+ related items
List Formatting
ul, ol {
padding-left: 1.5em;
margin: 1em 0;
}
li {
margin-bottom: 0.5em;
}
/* Nested lists */
ul ul, ol ol {
margin: 0.5em 0;
}List Best Practices
- Keep items parallel in structure
- Use consistent punctuation
- Don't make lists too long (7 ± 2 items)
- Consider breaking long lists into groups
Links and CTAs
Link Formatting
a {
color: #0066cc; /* Distinguishable color */
text-decoration: underline; /* Clear it's a link */
}
a:hover {
color: #004499;
text-decoration: none;
}
a:visited {
color: #551a8b; /* Different from unvisited */
}
a:focus {
outline: 2px solid #0066cc; /* Keyboard accessibility */
}Link Text
❌ Bad: Click here for more information
❌ Bad: More info
✅ Good: Read our complete guide to text formatting
✅ Good: Download the accessibility checklistCall-to-Action Buttons
.cta-button {
display: inline-block;
padding: 12px 24px;
font-size: 1rem;
font-weight: 600;
text-transform: uppercase; /* Acceptable for short CTAs */
letter-spacing: 0.5px;
background: #0066cc;
color: white;
border-radius: 4px;
}Accessibility Formatting
Color Contrast
- Normal text: 4.5:1 contrast ratio minimum
- Large text (18px+): 3:1 minimum
- UI components: 3:1 minimum
Don't Rely on Color Alone
❌ Bad: Required fields are in red
✅ Good: Required fields are marked with an asterisk (*)Screen Reader Considerations
- Use semantic HTML (headings, lists, etc.)
- Provide alt text for images
- Use ARIA labels when needed
- Ensure logical reading order
Code and Technical Text
Inline Code
<p>Use the <code>margin</code> property for spacing.</p>code {
font-family: "Fira Code", "Consolas", monospace;
background: #f4f4f4;
padding: 2px 6px;
border-radius: 3px;
font-size: 0.9em;
}Code Blocks
<pre><code class="language-javascript">
function hello() {
console.log("Hello, World!");
}
</code></pre>pre {
background: #1e1e1e;
color: #d4d4d4;
padding: 1em;
overflow-x: auto;
border-radius: 4px;
}Tables
When to Use Tables
- Comparing data across categories
- Displaying structured information
- NOT for layout purposes
Table Formatting
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background: #f5f5f5;
font-weight: 600;
}
/* Responsive table */
@media (max-width: 600px) {
table {
display: block;
overflow-x: auto;
}
}Dark Mode Considerations
Adapting to Dark Mode
/* Light mode defaults */
:root {
--text-color: #333333;
--bg-color: #ffffff;
--link-color: #0066cc;
}
/* Dark mode */
@media (prefers-color-scheme: dark) {
:root {
--text-color: #e0e0e0;
--bg-color: #1a1a1a;
--link-color: #6699ff;
}
}
body {
color: var(--text-color);
background: var(--bg-color);
}Dark Mode Tips
- Don't use pure black (#000) - use dark gray
- Reduce contrast slightly (white on black is harsh)
- Ensure images and icons work in both modes
- Test thoroughly with real users
Mobile Formatting
Touch Targets
- Minimum 44×44 pixels for tap targets
- Adequate spacing between interactive elements
- Consider thumb reach zones
Responsive Typography
html {
font-size: 16px;
}
@media (max-width: 768px) {
html {
font-size: 14px;
}
}
/* Use relative units */
h1 { font-size: 2rem; } /* Scales with base */
p { font-size: 1rem; }Conclusion
Great text formatting is invisible—readers absorb content without struggling with the presentation. By following these best practices for typography, hierarchy, and accessibility, you create content that's readable, engaging, and inclusive.
Use our text tools to ensure your content is properly formatted before publishing. From case conversion to word counting, the right formatting makes all the difference.
Try Our Free Tools
Put these tips into practice with our free online tools. No signup required.
Explore Tools