Welcome to Day 4 of the 180 Days of Frontend Development Challenge. Today, we'll explore how to structure text content using HTML's core text elements – the building blocks of all web content.
Why Text Structure Matters
Properly formatted text:
- Improves readability for users
- Helps search engines understand your content
- Creates visual hierarchy on your page
Core HTML Text Elements
1. Headings (<h1>
to <h6>
)
Headings create content hierarchy. Use them in order from most important (<h1>
) to least important (<h6>
).
<h1>Main Page Title (Only use one per page)</h1>
<h2>Section Heading</h2>
<h3>Subsection Heading</h3>
Best Practice:
- Use only one
<h1>
per page (for SEO) - Maintain logical heading order (don't skip levels)
2. Paragraphs (<p>
)
The workhorse of text content:
<p>This is a paragraph. Browsers automatically add spacing before and after.</p>
<p>Another paragraph here. Notice the space between paragraphs.</p>
3. Line Breaks (<br>
)
For forcing new lines within text (no closing tag needed):
<p>First line<br>Second line<br>Third line</p>
⚠️ Warning: Don't overuse <br>
for spacing – use CSS margins/padding instead.
4. Horizontal Rules (<hr>
)
Creates thematic breaks between sections:
<p>Content above the divider</p>
<hr>
<p>Content below the divider</p>
Customization (with attributes):
<hr size="3" color="blue" width="50%">
Hands-On Practice
Create a simple "About Me" page using all text elements:
<h1>About Jane Doe</h1>
<hr>
<h2>Professional Background</h2>
<p>Frontend developer with 5 years experience<br>
Specializing in responsive design</p>
<h2>Hobbies</h2>
<p>Photography<br>
Hiking<br>
Reading sci-fi novels</p>
<hr>
<p>Contact me at: jane@example.com</p>
Common Mistakes to Avoid
- Using headings just for styling (use CSS instead)
- Skipping heading levels (e.g.,
<h1>
→<h3>
) - Overusing
<br>
tags to create space - Forgetting to close
<p>
tags
Today's Challenge
- Create an HTML file with:
- One
<h1>
- Two
<h2>
sections - Paragraphs in each section
- Appropriate
<hr>
dividers
- One
- Experiment with
<br>
in paragraphs
Continue Learning
Dive deeper with the "Learn Frontend Development in 180 Days" ebook:
📖 Get the Ebook
Tip: View the source code of your favorite websites (Right-click → "View Page Source") to see how professionals structure text.
See you on Day 5!
On to day 5