Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST

HTML and CSS Text Content


HTML & CSS: Text Content

Headings, paragraphs, emphasis, and inline semantics give structure and meaning to your text.

CSS typography rules bring the words to life.


Headings establish hierarchy

Use one <h1> per page, followed by <h2>, <h3>, etc.

This improves accessibility and SEO.

Note: Accessibility means assistive technologies can understand the page, and SEO (search engine optimization) helps your site appear in search results.

Headings

<h1>Welcome to Campfire</h1>
<h2>Latest Updates</h2>
<h3>Release 2.0</h3>
Try it Yourself »

If you want to read more about headings or get an in-depth understanding, go to our Headings in the HTML tutorial.


Paragraphs and line breaks

  • <p> wraps paragraphs of text.
  • <br> inserts a line break (use sparingly).
  • <hr> draws thematic breaks between topics.

If you want to read more about paragraphs or get an in-depth understanding, go to our Paragraphs in the HTML tutorial.



Inline emphasis and semantics

  • <strong> - strong importance, typically bold.
  • <em> - emphasized text, typically italic.
  • <mark> - highlight; <code> - monospace code snippet.
  • <abbr>, <cite>, <time> add meaning for readers and crawlers.

If you want to read more about text semantics or get an in-depth understanding, see Formatting and Quotation elements in the HTML tutorial.


Control typography with CSS

Combine semantic markup with font families, weights, and spacing.

Typography example

<article class="story">
  <h1>A Future with HTML & CSS</h1>
  <p class="lead">Learn once, build everywhere.</p>
  <p>We explore accessible patterns, responsive layouts, and component libraries.</p>
</article>
body {
  font-family: "Inter", sans-serif; 
  margin:0; 
  background:#f7f8fc; 
  color:#1f2937;
}
.story {
  max-width:680px; 
  margin:80px auto; 
  padding:0 24px;
}
.story h1 {
  font-size:2.75rem; 
  line-height:1.15; 
  margin-bottom:12px;
}
.story .lead {
  font-size:1.25rem; 
  color:#4b5563; 
  margin-bottom:24px;
}
.story p {
  line-height:1.8;
}
Try it Yourself »

If you want to read more about typography or get an in-depth understanding, see Fonts, Font Size, and Text in the CSS tutorial.


Whitespace and rhythm

Use CSS line-height, margin, and letter-spacing to improve readability.

Maintain consistent spacing scale (4px, 8px, etc.).

Note: A spacing scale is a simple list of numbers you reuse (for example 4, 8, 12) so gaps feel balanced.

Example

<!DOCTYPE html>
<html>
<head>
<title>Typography Sample</title>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body>
  <h1>Designing with type</h1>
  <p>Great interfaces balance hierarchy, rhythm, and contrast.</p>
  <p>Use <mark>semantic tags</mark> to describe meaning, then layer styles.</p>
</body>
</html>
body {
  margin:0; 
  padding:48px; 
  font-family:"Georgia", serif; 
  background:#fdfcf8;
}
h1 {
  font-size:3rem; 
  margin-bottom:12px;
}
p {
  font-size:1.125rem; 
  line-height:1.7;
}
mark {
  background:#fff176; 
  padding:0 4px;
}
Try it Yourself »


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.