10 Tips for Learning to Code
-Tip 1: Practice Every Day
-Consistency beats intensity...
-Tip 2: Build Small Projects
-Projects turn theory into skill...
-`. They are different.
-:::note About "resetting" heading levels inside sections
-Early HTML5 drafts proposed that every `` could restart its own heading levels at ``. **Browsers never implemented this**, and screen readers do not use it. So always use the real heading level that matches the page's overall outline, even inside sections and articles.
-:::
+| Element | Where it appears | Purpose |
+| :-- | :-- | :-- |
+| `` | Browser tab and search results | Names the page for browsers and search engines |
+| `` | Inside the page content | Names the page for the reader |
-## A Note on Subheadings and Taglines
+They are often similar, but they do not have to match exactly.
-Sometimes a heading has a subtitle or tagline, like "The Complete Guide" beneath "Learning HTML." A subtitle is not a new section, so it should **not** be another heading level. Use a paragraph instead:
+## Practice
-```html
-Learning HTML
-
The complete beginner's guide to building web pages
-```
+Try this in your editor.
-HTML also has an `` element for grouping a heading with its subtitle, but the simple heading-plus-paragraph pattern above works everywhere and is perfectly fine for beginners.
+1. Create a file called `recipe.html`.
+2. Add an `` with the name of a dish.
+3. Add two `` headings: **Ingredients** and **Steps**.
+4. Under **Steps**, add an `` for each stage, such as **Prepare** and **Cook**.
+5. Add a short `
` under every heading.
+6. Read only the headings. Does the outline tell the story of the recipe?
-## Writing Great Headings
-
-Good headings are a writing skill as much as a technical one. Keep these habits in mind:
-
-- **Be descriptive.** "Getting Started with Git" beats "Getting Started."
-- **Be concise.** A heading is a label, not a sentence from the middle of a paragraph.
-- **Be unique.** Avoid repeating the same heading text many times on one page.
-- **Be parallel.** If your headings are "Installing Git" and "Configuring Git," keep that pattern instead of switching to "How Do I Make Commits?"
-- **Never leave one empty.** An empty heading confuses assistive technology and adds nothing.
-
-## Common Heading Mistakes
-
-
- 1. Choosing a heading level for its size
-
-```html
-
-Our Company History
-
-
-Our Company History
-```
-
-
-
-
- 2. Using bold paragraphs instead of headings
-
-```html
-
-Contact Us
-
-
-Contact Us
-```
-
-
-
-
- 3. Skipping heading levels
-
-Jumping from `` straight to `` breaks the outline. Move down one level at a time.
-
-
-
-
- 4. Having no h1, or an h1 that does not match the page
-
-Every page should have a clear `` that describes its main topic. A page whose first heading is an ``, or whose `` is only the site logo text on every page, loses much of the structure benefit.
-
-
-
-
- 5. Using headings for layout or spacing
-
-Do not wrap unrelated text in a heading just to push content down or make it stand out. Use CSS margins and padding for spacing.
-
-
-
-## Try It Yourself
-
-This travel blog snippet has a broken heading structure. Can you spot at least four problems?
-
-```html title="broken-headings.html"
-
My Travel Blog
-Day 1: Paris
-Morning
-Afternoon
-Day 2: Rome
-Evening
-```
-
-
- π Click to reveal the solution
-
-```html title="fixed-headings.html"
-My Travel Blog
-Day 1: Paris
-Morning
-Afternoon
-Day 2: Rome
-Evening
-```
-
-1. The main title "My Travel Blog" was an ``, but it should be the page's ``.
-2. "Day 1: Paris" was the ``, but it is a major section, so it becomes an ``.
-3. "Morning" and "Afternoon" jumped to ``, skipping ``. They become ``.
-4. "Evening" was a styled paragraph faking a heading, so it became a real ``.
-
-
-
## Quick Recap
-- HTML has six heading levels, **`` to ``**, forming the **outline** of your page.
-- Use **one ``** per page as the main title, and go down **one level at a time**.
-- Choose a heading level for **meaning and structure**, never for size. Use **CSS** to change how it looks.
-- Good headings help **SEO** by describing your page's topics clearly.
-- Real headings power **accessibility**, letting screen reader users skim and jump between sections.
-- Headings can contain **inline elements**, and combined with `id`, they can be **link targets**.
-- A subtitle is usually a **paragraph**, not another heading level.
-
-## Frequently Asked Questions
+Click a question to reveal the answer.
- How many h1 tags should a page have?
+1. How many heading levels does HTML have?
-HTML allows more than one, but using a single `` per page is the widely recommended practice. It keeps the page's main topic clear for visitors, search engines, and assistive technology.
+Six, from `` to ``.
- What is the difference between h1 and title?
+2. How many `` elements should a page normally have?
-The `` element lives in the `` and appears in the browser tab and search results. The `` lives in the `` and is the main visible heading of the page content. They are usually related, but they are separate elements.
+One. It is the main title of the page.
- Can I skip heading levels, like going from h2 to h4?
+3. Why should you not use `` just to get smaller text?
-You should avoid it. Skipping levels breaks the logical outline and can confuse screen reader users. Go down one level at a time, though you may jump back up to a higher level when starting a new section.
+The heading level shows rank in the outline, not size. Use CSS to change how big text looks.
- How do I make a heading smaller without changing its level?
+4. Which two groups of users benefit most from a correct heading outline?
-Use CSS, for example `h2 { font-size: 1.2rem; }`. The heading level describes structure, while CSS controls appearance.
+Screen reader users, who navigate by headings, and search engines, which use headings to understand the page.
- Do headings affect SEO?
+5. What is the difference between `` and ``?
-Yes. Search engines use headings to understand the structure and topics of a page. Clear, descriptive headings that reflect real content help, but keyword stuffing does not.
+`` shows in the browser tab and search results. `` shows inside the page as its visible title.
-
- Should I use h5 and h6?
-
-Rarely. Most pages are well served by h1 through h3, and sometimes h4. If you find yourself needing h5 or h6 often, consider whether your content could be split into separate sections or pages.
+## Key Takeaways
-
+- HTML has six heading levels, `` (most important) to `` (least important).
+- Headings build the **outline** of your page.
+- Use one `` and never skip levels.
+- Pick headings for **meaning**, and use CSS for **appearance**.
+- Good headings help SEO, accessibility, and readability.
-## Test Your Understanding
-
-1. What is the difference in meaning between `` and ``?
-2. Why is it a bad idea to choose `` just because it looks the right size?
-3. What does it mean to "skip a heading level," and why should you avoid it?
-4. How does a screen reader user benefit from real headings?
-5. Where should a subtitle like "The complete beginner's guide" go?
-
-
-
\ No newline at end of file
+Next, learn how to write body text in [Paragraphs](./paragraphs).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/horizontal-rule.mdx b/tutorials/html/03-text-content/horizontal-rule.mdx
index 8c9aa1236..f41fbd466 100644
--- a/tutorials/html/03-text-content/horizontal-rule.mdx
+++ b/tutorials/html/03-text-content/horizontal-rule.mdx
@@ -1,15 +1,339 @@
---
-id: horizontal-rule
-title: "Horizontal Rules: The hr Tag for Thematic Breaks"
+id: html-horizontal-rule
+title: "HTML Horizontal Rule"
sidebar_label: "Horizontal Rule"
sidebar_position: 5
slug: /html/text-content/horizontal-rule
-description: "Explore the hr element in HTML to create thematic breaks, section dividers, and visual content shifts across web pages."
+description: "Learn how to use the HTML hr tag to mark a thematic break between topics. Understand its meaning, default look, how to style it with CSS, accessibility tips, and common mistakes, explained clearly on CodeHarborHub."
keywords:
+ - HTML horizontal rule
- HTML hr tag
- - horizontal rule
- - thematic break HTML
- - section divider HTML
+ - HTML thematic break
+ - style hr with CSS
+ - HTML divider line
+ - HTML hr accessibility
+ - HTML void elements
+ - HTML separator
+ - learn HTML hr
- CodeHarborHub HTML
-tags: [html, hr-tag, layout, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, horizontal-rule, text, frontend]
+---
+
+Think about reading a story. Suddenly the writer leaves a small gap, maybe adds a line or a few stars, and starts again in a new place or at a new time. You feel the change right away. Nobody had to explain it.
+
+HTML has a tool for exactly this moment: the **horizontal rule**, written as `
`. It draws a line across the page, but its real job is not decoration. It tells the reader, "The topic is changing here."
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag is and what it means
+- When a horizontal rule is the right choice
+- How to style it with CSS, since old HTML attributes are outdated
+- How screen readers treat it
+- Common mistakes, and better alternatives
+
+## The Basics
+
+The `
` tag creates a **thematic break** between two blocks of content. It is a **void element**, which means it has no content inside and no closing tag. (You met void elements in the [Line Breaks](./line-breaks) lesson.)
+
+
+
+
+```html title="index.html"
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+```
+
+
+
+
+
+<>
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+>
+
+
+
+
+
+The browser draws a thin line across the full width of its container, with a little space above and below. It is a block-level element, so it always sits on its own row.
+
+:::info Two ways to write it
+In plain HTML, both `
` and `
` work. In MDX and JSX, use `
`, because unclosed tags cause errors there.
+:::
+
+## What Does "Thematic Break" Mean?
+
+In older HTML, `
` meant "horizontal **rule**", so people thought of it only as a line. In modern HTML, the meaning is a **shift in theme** at the paragraph level.
+
+Here is the difference in simple terms.
+
+| Old idea | Modern idea |
+| :-- | :-- |
+| "Draw a line here." | "The subject changes here." |
+| About appearance | About meaning |
+| Visual decoration | Content structure |
+
+That is why the line you see is only the **default look**. The meaning stays even if you restyle it.
+
+## When to Use `
`
+
+Use it when there is a real change of topic inside a section, but the change is too small for a new heading.
+
+- **A scene change** in a story
+- **A shift in subject** between two paragraphs
+- **A separator** between a main article and its notes or sign-off
+- **A pause** between a question and its long answer
+
+
+
+
+```html title="story.html"
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+```
+
+
+
+
+
+<>
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+>
+
+
+
+
+
+A quick test: **if you removed the line, would the change of topic still be clear?** If yes, you probably do not need `
`. If a reader might get confused, it helps.
+
+## Old Attributes Are Gone: Use CSS
+
+Old tutorials show attributes like `width`, `size`, `align`, and `noshade` on `
`. These are **deprecated**. They still work in some browsers, but you should not use them. CSS gives you full control instead.
+
+| Old attribute | Modern CSS |
+| :-- | :-- |
+| `width="50%"` | `width: 50%;` |
+| `size="5"` | `border-width` or `height` |
+| `align="center"` | `margin-inline: auto;` |
+| `noshade` | `border-style` and `background` |
+
+### A Clean Custom Line
+
+
+
+
+```html title="styled-hr.html"
+
+
+First topic.
+
+Second topic.
+```
+
+
+
+
+
+<>
+First topic.
+
+Second topic.
+>
+
+
+
+
+
+### A Few More Styles
+
+
+
+
+```css
+hr.dashed {
+ border: none;
+ border-top: 2px dashed #64748b;
+}
+```
+
+
+
+
+```css
+hr.fade {
+ height: 2px;
+ border: none;
+ background: linear-gradient(to right, transparent, #2563eb, transparent);
+}
+```
+
+
+
+
+```css
+hr.dotted {
+ border: none;
+ border-top: 4px dotted #94a3b8;
+ width: 30%;
+ margin-inline: auto;
+}
+```
+
+
+
+
+:::tip Reset first
+Browsers add their own border style and margin to `
`. Setting `border: none` first, then adding the style you want, gives you a predictable result in every browser.
+:::
+
+## Accessibility and Global Readers
+
+Not everyone sees the page in the same way, so it helps to know what happens behind the scenes.
+
+- **Screen readers** usually announce `
` as a **separator**. Some readers skip it, and others say the word. This is why you should use it only when the break is meaningful.
+- **Decorative lines** made with CSS borders are ignored by assistive tools. That is good when the line is only for looks.
+- **Contrast matters.** A very light gray line on a white background may be invisible for low-vision users. Choose a color that can be seen.
+- **Right-to-left languages** such as Arabic and Hebrew work fine with `
`, because it spans the full width of its container.
+- **Do not rely on the line alone.** If a new section is important, add a heading, which also helps translation tools and search engines.
+
+## Choosing the Right Tool
+
+`
` is not the only way to separate content. Pick the tool that matches your goal.
+
+| Goal | Best choice |
+| :-- | :-- |
+| Change of topic inside a section | `
` |
+| A new major section of the page | A heading, like `` |
+| A purely visual line, such as under a title | CSS `border-bottom` |
+| Space between two blocks | CSS `margin` or `padding` |
+| Separate items in a list | Use list styling or `border` on each item |
+
+## Common Mistakes
+
+### Mistake 1: Using `
` everywhere
+
+```html
+
+
Paragraph one.
+
+Paragraph two.
+
+Paragraph three.
+
+```
+
+When every paragraph gets a line, the break loses its meaning. Save it for real changes of topic.
+
+### Mistake 2: Using it only for decoration
+
+If you only want a line under a title, a CSS `border-bottom` is the better tool. It does not say "the topic changed" when nothing changed.
+
+### Mistake 3: Using deprecated attributes
+
+```html
+
+
+
+
+
+```
+
+### Mistake 4: Writing a closing tag
+
+`` is not valid. Void elements never have a closing tag.
+
+### Mistake 5: Using it instead of headings
+
+A line does not tell users what the next section is about. If the next part has its own subject, give it a [heading](./headings).
+
+## Try It Yourself
+
+Here is a small exercise.
+
+1. Create a file called `travel-diary.html`.
+2. Write two short paragraphs about a place you visited or want to visit.
+3. Add a third paragraph about a **different day** or a **different place**.
+4. Place an `
` between the parts where the story changes.
+5. Add a CSS class that makes your line 40% wide, centered, and dotted.
+6. Remove the `
` and read the text again. Is the change still clear?
+
+
+
+
+## Quick Recap
+
+Click a question to check your answer.
+
+
+1. What does `
` represent in modern HTML?
+
+A thematic break, meaning a shift in topic between blocks of content.
+
+
+
+
+2. Does `
` need a closing tag?
+
+No. It is a void element and has no content to wrap.
+
+
+
+
+3. How should you change the width or color of a horizontal rule today?
+
+Use CSS, such as `width`, `border-top`, and `margin`. The old HTML attributes are deprecated.
+
+
+
+
+4. When is a heading better than `
`?
+
+When the next part is a new section with its own subject. A heading names that section, and a line does not.
+
+
+
+
+5. Why should you not use `
` between every paragraph?
+
+Too many breaks make each one meaningless, and screen readers may announce a separator every time.
+
+
+
+## Key Takeaways
+
+- `
` marks a **change of theme**, not just a line on the screen.
+- It is a **void, block-level** element with no closing tag.
+- Style it with **CSS**. The old attributes are deprecated.
+- Use it sparingly, and prefer headings for new sections and CSS borders for decoration.
+- Choose visible colors and think about screen readers so every learner can follow your page.
+
+Next, learn how to show importance and attention in your text with [Strong and Bold](./strong-and-bold).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/line-breaks.mdx b/tutorials/html/03-text-content/line-breaks.mdx
index 57c239bf5..c5ddb3059 100644
--- a/tutorials/html/03-text-content/line-breaks.mdx
+++ b/tutorials/html/03-text-content/line-breaks.mdx
@@ -1,15 +1,367 @@
---
-id: line-breaks
-title: "Line Breaks and Forced Spaces in HTML"
+id: html-line-breaks
+title: "HTML Line Breaks"
sidebar_label: "Line Breaks"
sidebar_position: 4
slug: /html/text-content/line-breaks
-description: "Learn when and how to use the self-closing br tag for forcing line breaks in addresses, poetry, and inline text blocks without breaking paragraphs."
+description: "Understand how the HTML br tag works, when to use a line break instead of a new paragraph, how to handle addresses and poems, and which CSS options and mistakes to know. A clear, step-by-step guide on CodeHarborHub."
keywords:
+ - HTML line break
- HTML br tag
- - line break tag
- - forced line breaks
- - inline breaks HTML
+ - HTML br vs p
+ - HTML new line
+ - HTML wbr tag
+ - HTML white-space pre-line
+ - HTML void elements
+ - HTML address formatting
+ - learn HTML line breaks
- CodeHarborHub HTML
-tags: [html, line-breaks, formatting, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, line-break, text, frontend]
+---
+
+In the last lesson you learned that pressing Enter in your code does **not** start a new line on the page. The browser ignores it. So what do you do when you really do want a new line, such as in an address or a poem, without starting a whole new paragraph?
+
+That is the job of the `
` tag. It is tiny, but understanding **when** to use it (and when not to) is what separates clean HTML from messy HTML. This lesson explains both.
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag does, in plain terms
+- What a **void element** is and why `
` has no closing tag
+- The difference between a line break and a new paragraph
+- Where line breaks make sense, and where they do not
+- Better alternatives using CSS
+- How to control where a long word may break with ` `
+
+## The Problem: Enter Does Nothing
+
+Start with the problem. Here is a short message typed on three lines.
+
+
+
+
+```html title="problem.html"
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+```
+
+
+
+
+
+<>
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+>
+
+
+
+
+
+All three lines run together into one. As you learned, the browser **collapses** line breaks in your code into a single space. To tell the browser "start a new line here", we need an actual HTML instruction.
+
+## The Solution: The `
` Tag
+
+`br` stands for **break**. Place it exactly where you want the line to end.
+
+
+
+
+```html title="solution.html"
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+```
+
+
+
+
+
+<>
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+>
+
+
+
+
+
+Now each line stands on its own, and they all still belong to **one paragraph**.
+
+## How to Think About `
`
+
+Here is a simple way to picture it.
+
+- **Typing text** is like writing on a typewriter. The words keep flowing to the right until the paper edge, then wrap.
+- **`
`** is like pressing the carriage return on that typewriter. The next word starts at the beginning of a new line, even though you were not at the edge yet.
+
+That is all it does. It does not create a new block, and it does not add extra space. It only says, "continue from the next line."
+
+## Void Elements: Why No Closing Tag?
+
+Most HTML elements wrap around content, like `text
`. The `
` tag has **nothing to wrap**, because a line break has no content inside it. Elements like this are called **void elements**.
+
+| Wrapping element | Void element |
+| :-- | :-- |
+| `Hello
` | `
` |
+| `Hi` | `
` |
+| `Link` | `
` |
+
+You may see three ways of writing it, and all of them work in HTML.
+
+```html
+
+
+
+```
+
+:::info Which one should I use?
+In plain HTML, `
` is perfectly valid. The self-closing form `
` is required in JSX and MDX, and it is common in many style guides. Since our CodeHarborHub docs run on MDX, `
` is the safest habit.
+:::
+
+## Line Break vs New Paragraph
+
+This is the most important idea in the lesson. Both give you a new line, but they mean different things.
+
+| | `
` | `` |
+| :-- | :-- | :-- |
+| Meaning | "Same thought, next line" | "A new idea starts here" |
+| Extra space between lines | No | Yes (default margin) |
+| Structure | Stays inside one element | Creates a separate block |
+| Best for | Addresses, poems, sign-offs | Normal body text |
+
+A quick test: **if you could put a full stop and start a new idea, use a new paragraph. If the lines belong together as one unit, use a line break.**
+
+### Side by Side
+
+
+
+
+```html title="compare.html"
+
+I woke up early today.
+Then I went for a long walk.
+
+
+
+ Priya Sharma
+ 221B Green Street
+ Indore, Madhya Pradesh
+
+```
+
+
+
+
+
+<>
+I woke up early today.
+Then I went for a long walk.
+
+
+ Priya Sharma
+ 221B Green Street
+ Indore, Madhya Pradesh
+
+>
+
+
+
+
+
+Look at the gaps. The two paragraphs have space between them. The address lines sit close together because they are one block of information.
+
+## Where Line Breaks Make Sense
+
+Use `
` when the **line ending itself is part of the content**.
+
+- **Postal addresses:** name, street, and city on separate lines
+- **Poems and verses:** each line has to stay where the poet put it
+- **Sign-offs:** "Thanks," then your name on the next line
+- **Short labeled lines:** for example, contact details in a footer
+
+```html title="signoff.html"
+
+ Thanks for reading,
+ Team CodeHarborHub
+
+```
+
+## Where Line Breaks Do Not Belong
+
+### Do not use `
` to create space
+
+```html
+
+First idea.
+
+Second idea.
+```
+
+Stacking breaks is a layout trick, not meaning. It behaves differently on different screen sizes, and screen readers may announce the empty lines. Use CSS `margin` instead.
+
+```html
+
+First idea.
+Second idea.
+```
+
+### Do not use `
` to split every sentence into a paragraph
+
+If your lines are separate ideas, write separate `` elements. It makes the structure clear to search engines and assistive tools.
+
+### Do not use `
` inside lists or tables to fake layout
+
+There are proper elements for lists and tables. Reaching for `
` there is usually a sign that another tag fits better.
+
+:::warning Accessibility note
+Screen readers treat line breaks inside text as part of the reading flow. Real structure, like separate paragraphs or list items, gives users clearer signals than many `
` tags in a row.
+:::
+
+## Better Options with CSS
+
+Sometimes you have text that already contains line endings, like content from a database or a text box. Instead of adding `
` by hand, CSS can honor the line breaks for you.
+
+
+
+
+```html title="pre-line.html"
+
+
+
+Line one of my note
+Line two of my note
+Line three of my note
+
+```
+
+
+
+
+
+<>
+
+Line one of my note
+Line two of my note
+Line three of my note
+
+>
+
+
+
+
+
+`white-space: pre-line` tells the browser: "keep the line breaks I typed, but still collapse extra spaces." It is handy for user-written text.
+
+| Need | Best tool |
+| :-- | :-- |
+| One or two deliberate line endings (address, poem) | `
` |
+| Many stored line endings in existing text | CSS `white-space: pre-line` |
+| Exact spaces and line breaks, like code | The `
` element |
+| Extra space between blocks | CSS `margin` or `padding` |
+| A new idea | A new `` |
+
+## Bonus: The ` ` Tag
+
+`
` **forces** a break. Its quieter cousin, ` ` (word break opportunity), only **suggests** one. The browser breaks the line there **only if it needs to**.
+
+That helps with very long words or URLs that could overflow a small screen.
+
+```html
+
+ Read our guide at
+ https://codeharborhub. github. io/tutorial /html /text-content
+
+```
+
+On a wide screen, the text looks normal. On a narrow phone, the browser can wrap at any ` ` instead of overflowing.
+
+## Common Mistakes
+
+| Mistake | Why it is a problem | Fix |
+| :-- | :-- | :-- |
+| Writing `` | It is not valid HTML | Use `
` |
+| Many `
` in a row for spacing | Layout trick, poor accessibility | Use CSS `margin` |
+| A `
` right after every sentence | Turns body text into a choppy list | Use real paragraphs |
+| Using `
` outside any text container | Can produce unpredictable spacing | Put it inside `` or another text element |
+
+## Try It Yourself
+
+Practice with this small project.
+
+1. Create `contact-card.html`.
+2. Add an `
` that says **Contact Us**.
+3. Inside one `
`, write your name, city, and email on **three lines** using `
`.
+4. Add a **second** `
` with a normal sentence, like "We reply within a day."
+5. Compare the spacing between the two blocks. Can you explain why the gaps look different?
+
+If you can explain it, you truly understand line breaks.
+
+
+
+
+## Quick Recap
+
+Click a question to check your answer.
+
+
+1. What does `
` do?
+
+It ends the current line and starts the text on a new line, without starting a new paragraph.
+
+
+
+
+2. Why does `
` have no closing tag?
+
+It is a void element. A line break has no content to wrap, so there is nothing to close.
+
+
+
+
+3. When should you choose `` over `
`?
+
+When you are starting a new idea. Use `
` only when the lines belong together as one unit, like an address.
+
+
+
+
+4. Why is stacking several `
` tags a poor way to add space?
+
+It mixes layout with content, behaves inconsistently on different screens, and is not friendly to screen readers. CSS margin is better.
+
+
+
+
+5. What is the difference between `
` and ` `?
+
+`
` always forces a break. ` ` only allows a break if the text needs one, such as in a long word on a small screen.
+
+
+
+## Key Takeaways
+
+- Pressing Enter in your code does not create a new line on the page. Use `
` for that.
+- `
` is a **void element**. It has no content and no closing tag.
+- Use `
` when the line ending is part of the content, such as addresses, poems, and sign-offs.
+- Use `
` for new ideas, and CSS for spacing.
+- `white-space: pre-line` keeps existing line breaks, and ` ` suggests optional break points.
+
+Next, learn how to separate topics with a visual divider in [Horizontal Rule](./horizontal-rule).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/paragraphs.mdx b/tutorials/html/03-text-content/paragraphs.mdx
index 426b34192..dd10eb906 100644
--- a/tutorials/html/03-text-content/paragraphs.mdx
+++ b/tutorials/html/03-text-content/paragraphs.mdx
@@ -1,15 +1,332 @@
---
-id: paragraphs
-title: "HTML Paragraphs: Structuring Blocks of Text"
+id: html-paragraphs
+title: "HTML Paragraphs"
sidebar_label: "Paragraphs"
sidebar_position: 3
slug: /html/text-content/paragraphs
-description: "Understand the paragraph tag, block-level text rendering, browser default margins, and proper text grouping techniques in HTML."
+description: "Learn how to write paragraphs in HTML with the p tag. Understand how browsers handle spaces and line breaks, how to style paragraphs with CSS, and how to avoid common beginner mistakes, explained in simple language on CodeHarborHub."
keywords:
+ - HTML paragraphs
+ - HTML p tag
- HTML paragraph tag
- - p tag HTML
- - block level text
- - text blocks HTML
+ - HTML whitespace collapsing
+ - HTML block level elements
+ - style HTML paragraphs with CSS
+ - HTML paragraph best practices
+ - learn HTML paragraphs
- CodeHarborHub HTML
-tags: [html, paragraph, markup, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, paragraphs, text, frontend]
+---
+
+Imagine opening a book where every page is one giant wall of words. No gaps, no breaks, nothing to rest your eyes on. You would probably close it after a few lines, right?
+
+That is exactly why **paragraphs** exist. They chop your writing into small, friendly chunks so readers can breathe, follow your ideas, and keep going. In HTML, the tool for that job is the humble `
` tag, and it is one you will use in almost every page you ever build.
+
+
+
+
+## What You Will Learn
+
+By the end of this lesson, you will be able to:
+
+- Write a paragraph with the `
` tag
+- Understand why your extra spaces and blank lines seem to "disappear"
+- Style paragraphs with CSS so they are comfortable to read
+- Avoid the mistakes almost every beginner makes at least once
+
+:::info Good news
+This is one of the easiest lessons in the whole tutorial. If you can type a sentence, you can write a paragraph.
+:::
+
+## Your First Paragraph
+
+A paragraph starts with `
` and ends with `
`. Everything you put between the two tags becomes one paragraph.
+
+
+
+
+```html title="index.html"
+Hello! This is my very first paragraph.
+And this is my second one. See how it starts on a new line?
+```
+
+
+
+
+
+<>
+Hello! This is my very first paragraph.
+And this is my second one. See how it starts on a new line?
+>
+
+
+
+
+
+Notice two things. Each paragraph starts on its own line, and the browser adds a little space between them. You did not have to ask for that. The browser does it for you.
+
+## Paragraphs Are "Block" Elements
+
+In HTML, a paragraph is a **block-level element**. Picture it as a rectangular box that stretches across the full width of its container. Because of that:
+
+- A paragraph always starts on a **new line**
+- It takes up the **whole row**, even if the text is short
+- The browser adds a **margin** above and below it (about 16px by default)
+
+Think of paragraphs like boxes on a shelf. Each box gets its own row, and there is a small gap between rows.
+
+## Why Did My Spaces Disappear?
+
+Here is something that surprises almost everyone at first. Look at this code.
+
+
+
+
+```html title="spaces.html"
+
+ This paragraph has
+ lots of extra spaces
+
+
+ and blank lines.
+
+```
+
+
+
+
+
+<>
+
+ This paragraph has
+ lots of extra spaces
+
+
+ and blank lines.
+
+>
+
+
+
+
+
+You typed a bunch of spaces and blank lines, but the browser shows one tidy line. That is not a bug. It is called **whitespace collapsing**. The browser squishes any run of spaces, tabs, and line breaks into a single space.
+
+Why does it work this way? So you can format your code however you like, with indentation and line wraps, without changing what visitors see.
+
+:::tip Want to keep your spacing?
+If you truly need spaces and line breaks preserved, you have two options. Use `
` for a line break (next lesson), or use the `` tag for preformatted text.
+:::
+
+## Long Text? Break It Up
+
+Compare these two versions of the same text. Which one would you rather read?
+
+
+
+
+```html
+
+ HTML is the skeleton of every web page. It tells the browser what is a title,
+ what is a paragraph, and what is a link. CSS then adds colors and layout, and
+ JavaScript brings the page to life with interaction. Learning all three takes
+ time, but starting with HTML gives you a strong base for everything else.
+
+```
+
+
+
+
+```html
+
+ HTML is the skeleton of every web page. It tells the browser what is a title,
+ what is a paragraph, and what is a link.
+
+
+ CSS then adds colors and layout, and JavaScript brings the page to life with
+ interaction.
+
+
+ Learning all three takes time, but starting with HTML gives you a strong base
+ for everything else.
+
+```
+
+
+
+
+A good rule of thumb: **one paragraph, one idea**. When your idea changes, start a new paragraph.
+
+## Styling Paragraphs with CSS
+
+The default look works, but a few small CSS tweaks can make your text much nicer to read.
+
+
+
+
+```html title="styled-paragraph.html"
+
+
+
+ Comfortable text is not an accident. A little extra line height and a limited
+ width make long paragraphs far easier on the eyes.
+
+```
+
+
+
+
+
+<>
+
+ Comfortable text is not an accident. A little extra line height and a limited
+ width make long paragraphs far easier on the eyes.
+
+>
+
+
+
+
+
+Here is what each property does:
+
+| CSS property | What it does | Friendly tip |
+| :-- | :-- | :-- |
+| `font-size` | Changes the text size | Keep body text at 16px or larger |
+| `line-height` | Sets the space between lines | Try 1.5 to 1.8 for easy reading |
+| `max-width` | Limits how wide the text can get | Around `60ch` to `75ch` works well |
+| `color` | Sets the text color | Make sure it contrasts with the background |
+| `text-align` | Aligns the text | Left-aligned is easiest for most readers |
+| `margin` | Changes the gap between paragraphs | Use `margin-bottom` for even spacing |
+
+## Mistakes Everyone Makes (and Easy Fixes)
+
+Do not worry if you have already done these. Every developer has.
+
+### Mistake 1: Using empty paragraphs for spacing
+
+```html
+
+First idea.
+
+
+Second idea.
+```
+
+Empty `` tags add noise, not meaning. If you want more space, use CSS `margin` or `padding` instead.
+
+### Mistake 2: Putting one paragraph inside another
+
+```html
+
+
+ Outer paragraph
+
Inner paragraph
+
+```
+
+Paragraphs cannot contain other paragraphs. The browser will quietly close the first one as soon as it sees the second, and your layout will not match what you wrote.
+
+### Mistake 3: Putting block elements inside a paragraph
+
+A `
`. **Browsers never implemented this**, and screen readers do not use it. So always use the real heading level that matches the page's overall outline, even inside sections and articles.
-:::
+| Element | Where it appears | Purpose |
+| :-- | :-- | :-- |
+| `` | Browser tab and search results | Names the page for browsers and search engines |
+| `` | Inside the page content | Names the page for the reader |
-## A Note on Subheadings and Taglines
+They are often similar, but they do not have to match exactly.
-Sometimes a heading has a subtitle or tagline, like "The Complete Guide" beneath "Learning HTML." A subtitle is not a new section, so it should **not** be another heading level. Use a paragraph instead:
+## Practice
-```html
-Learning HTML
-
The complete beginner's guide to building web pages
-```
+Try this in your editor.
-HTML also has an `` element for grouping a heading with its subtitle, but the simple heading-plus-paragraph pattern above works everywhere and is perfectly fine for beginners.
+1. Create a file called `recipe.html`.
+2. Add an `` with the name of a dish.
+3. Add two `` headings: **Ingredients** and **Steps**.
+4. Under **Steps**, add an `` for each stage, such as **Prepare** and **Cook**.
+5. Add a short `
` under every heading.
+6. Read only the headings. Does the outline tell the story of the recipe?
-## Writing Great Headings
-
-Good headings are a writing skill as much as a technical one. Keep these habits in mind:
-
-- **Be descriptive.** "Getting Started with Git" beats "Getting Started."
-- **Be concise.** A heading is a label, not a sentence from the middle of a paragraph.
-- **Be unique.** Avoid repeating the same heading text many times on one page.
-- **Be parallel.** If your headings are "Installing Git" and "Configuring Git," keep that pattern instead of switching to "How Do I Make Commits?"
-- **Never leave one empty.** An empty heading confuses assistive technology and adds nothing.
-
-## Common Heading Mistakes
-
-
- 1. Choosing a heading level for its size
-
-```html
-
-Our Company History
-
-
-Our Company History
-```
-
-
-
-
- 2. Using bold paragraphs instead of headings
-
-```html
-
-Contact Us
-
-
-Contact Us
-```
-
-
-
-
- 3. Skipping heading levels
-
-Jumping from `` straight to `` breaks the outline. Move down one level at a time.
-
-
-
-
- 4. Having no h1, or an h1 that does not match the page
-
-Every page should have a clear `` that describes its main topic. A page whose first heading is an ``, or whose `` is only the site logo text on every page, loses much of the structure benefit.
-
-
-
-
- 5. Using headings for layout or spacing
-
-Do not wrap unrelated text in a heading just to push content down or make it stand out. Use CSS margins and padding for spacing.
-
-
-
-## Try It Yourself
-
-This travel blog snippet has a broken heading structure. Can you spot at least four problems?
-
-```html title="broken-headings.html"
-
My Travel Blog
-Day 1: Paris
-Morning
-Afternoon
-Day 2: Rome
-Evening
-```
-
-
- π Click to reveal the solution
-
-```html title="fixed-headings.html"
-My Travel Blog
-Day 1: Paris
-Morning
-Afternoon
-Day 2: Rome
-Evening
-```
-
-1. The main title "My Travel Blog" was an ``, but it should be the page's ``.
-2. "Day 1: Paris" was the ``, but it is a major section, so it becomes an ``.
-3. "Morning" and "Afternoon" jumped to ``, skipping ``. They become ``.
-4. "Evening" was a styled paragraph faking a heading, so it became a real ``.
-
-
-
## Quick Recap
-- HTML has six heading levels, **`` to ``**, forming the **outline** of your page.
-- Use **one ``** per page as the main title, and go down **one level at a time**.
-- Choose a heading level for **meaning and structure**, never for size. Use **CSS** to change how it looks.
-- Good headings help **SEO** by describing your page's topics clearly.
-- Real headings power **accessibility**, letting screen reader users skim and jump between sections.
-- Headings can contain **inline elements**, and combined with `id`, they can be **link targets**.
-- A subtitle is usually a **paragraph**, not another heading level.
-
-## Frequently Asked Questions
+Click a question to reveal the answer.
- How many h1 tags should a page have?
+1. How many heading levels does HTML have?
-HTML allows more than one, but using a single `` per page is the widely recommended practice. It keeps the page's main topic clear for visitors, search engines, and assistive technology.
+Six, from `` to ``.
- What is the difference between h1 and title?
+2. How many `` elements should a page normally have?
-The `` element lives in the `` and appears in the browser tab and search results. The `` lives in the `` and is the main visible heading of the page content. They are usually related, but they are separate elements.
+One. It is the main title of the page.
- Can I skip heading levels, like going from h2 to h4?
+3. Why should you not use `` just to get smaller text?
-You should avoid it. Skipping levels breaks the logical outline and can confuse screen reader users. Go down one level at a time, though you may jump back up to a higher level when starting a new section.
+The heading level shows rank in the outline, not size. Use CSS to change how big text looks.
- How do I make a heading smaller without changing its level?
+4. Which two groups of users benefit most from a correct heading outline?
-Use CSS, for example `h2 { font-size: 1.2rem; }`. The heading level describes structure, while CSS controls appearance.
+Screen reader users, who navigate by headings, and search engines, which use headings to understand the page.
- Do headings affect SEO?
+5. What is the difference between `` and ``?
-Yes. Search engines use headings to understand the structure and topics of a page. Clear, descriptive headings that reflect real content help, but keyword stuffing does not.
+`` shows in the browser tab and search results. `` shows inside the page as its visible title.
-
- Should I use h5 and h6?
-
-Rarely. Most pages are well served by h1 through h3, and sometimes h4. If you find yourself needing h5 or h6 often, consider whether your content could be split into separate sections or pages.
+## Key Takeaways
-
+- HTML has six heading levels, `` (most important) to `` (least important).
+- Headings build the **outline** of your page.
+- Use one `` and never skip levels.
+- Pick headings for **meaning**, and use CSS for **appearance**.
+- Good headings help SEO, accessibility, and readability.
-## Test Your Understanding
-
-1. What is the difference in meaning between `` and ``?
-2. Why is it a bad idea to choose `` just because it looks the right size?
-3. What does it mean to "skip a heading level," and why should you avoid it?
-4. How does a screen reader user benefit from real headings?
-5. Where should a subtitle like "The complete beginner's guide" go?
-
-
-
\ No newline at end of file
+Next, learn how to write body text in [Paragraphs](./paragraphs).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/horizontal-rule.mdx b/tutorials/html/03-text-content/horizontal-rule.mdx
index 8c9aa1236..f41fbd466 100644
--- a/tutorials/html/03-text-content/horizontal-rule.mdx
+++ b/tutorials/html/03-text-content/horizontal-rule.mdx
@@ -1,15 +1,339 @@
---
-id: horizontal-rule
-title: "Horizontal Rules: The hr Tag for Thematic Breaks"
+id: html-horizontal-rule
+title: "HTML Horizontal Rule"
sidebar_label: "Horizontal Rule"
sidebar_position: 5
slug: /html/text-content/horizontal-rule
-description: "Explore the hr element in HTML to create thematic breaks, section dividers, and visual content shifts across web pages."
+description: "Learn how to use the HTML hr tag to mark a thematic break between topics. Understand its meaning, default look, how to style it with CSS, accessibility tips, and common mistakes, explained clearly on CodeHarborHub."
keywords:
+ - HTML horizontal rule
- HTML hr tag
- - horizontal rule
- - thematic break HTML
- - section divider HTML
+ - HTML thematic break
+ - style hr with CSS
+ - HTML divider line
+ - HTML hr accessibility
+ - HTML void elements
+ - HTML separator
+ - learn HTML hr
- CodeHarborHub HTML
-tags: [html, hr-tag, layout, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, horizontal-rule, text, frontend]
+---
+
+Think about reading a story. Suddenly the writer leaves a small gap, maybe adds a line or a few stars, and starts again in a new place or at a new time. You feel the change right away. Nobody had to explain it.
+
+HTML has a tool for exactly this moment: the **horizontal rule**, written as `
`. It draws a line across the page, but its real job is not decoration. It tells the reader, "The topic is changing here."
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag is and what it means
+- When a horizontal rule is the right choice
+- How to style it with CSS, since old HTML attributes are outdated
+- How screen readers treat it
+- Common mistakes, and better alternatives
+
+## The Basics
+
+The `
` tag creates a **thematic break** between two blocks of content. It is a **void element**, which means it has no content inside and no closing tag. (You met void elements in the [Line Breaks](./line-breaks) lesson.)
+
+
+
+
+```html title="index.html"
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+```
+
+
+
+
+
+<>
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+>
+
+
+
+
+
+The browser draws a thin line across the full width of its container, with a little space above and below. It is a block-level element, so it always sits on its own row.
+
+:::info Two ways to write it
+In plain HTML, both `
` and `
` work. In MDX and JSX, use `
`, because unclosed tags cause errors there.
+:::
+
+## What Does "Thematic Break" Mean?
+
+In older HTML, `
` meant "horizontal **rule**", so people thought of it only as a line. In modern HTML, the meaning is a **shift in theme** at the paragraph level.
+
+Here is the difference in simple terms.
+
+| Old idea | Modern idea |
+| :-- | :-- |
+| "Draw a line here." | "The subject changes here." |
+| About appearance | About meaning |
+| Visual decoration | Content structure |
+
+That is why the line you see is only the **default look**. The meaning stays even if you restyle it.
+
+## When to Use `
`
+
+Use it when there is a real change of topic inside a section, but the change is too small for a new heading.
+
+- **A scene change** in a story
+- **A shift in subject** between two paragraphs
+- **A separator** between a main article and its notes or sign-off
+- **A pause** between a question and its long answer
+
+
+
+
+```html title="story.html"
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+```
+
+
+
+
+
+<>
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+>
+
+
+
+
+
+A quick test: **if you removed the line, would the change of topic still be clear?** If yes, you probably do not need `
`. If a reader might get confused, it helps.
+
+## Old Attributes Are Gone: Use CSS
+
+Old tutorials show attributes like `width`, `size`, `align`, and `noshade` on `
`. These are **deprecated**. They still work in some browsers, but you should not use them. CSS gives you full control instead.
+
+| Old attribute | Modern CSS |
+| :-- | :-- |
+| `width="50%"` | `width: 50%;` |
+| `size="5"` | `border-width` or `height` |
+| `align="center"` | `margin-inline: auto;` |
+| `noshade` | `border-style` and `background` |
+
+### A Clean Custom Line
+
+
+
+
+```html title="styled-hr.html"
+
+
+First topic.
+
+Second topic.
+```
+
+
+
+
+
+<>
+First topic.
+
+Second topic.
+>
+
+
+
+
+
+### A Few More Styles
+
+
+
+
+```css
+hr.dashed {
+ border: none;
+ border-top: 2px dashed #64748b;
+}
+```
+
+
+
+
+```css
+hr.fade {
+ height: 2px;
+ border: none;
+ background: linear-gradient(to right, transparent, #2563eb, transparent);
+}
+```
+
+
+
+
+```css
+hr.dotted {
+ border: none;
+ border-top: 4px dotted #94a3b8;
+ width: 30%;
+ margin-inline: auto;
+}
+```
+
+
+
+
+:::tip Reset first
+Browsers add their own border style and margin to `
`. Setting `border: none` first, then adding the style you want, gives you a predictable result in every browser.
+:::
+
+## Accessibility and Global Readers
+
+Not everyone sees the page in the same way, so it helps to know what happens behind the scenes.
+
+- **Screen readers** usually announce `
` as a **separator**. Some readers skip it, and others say the word. This is why you should use it only when the break is meaningful.
+- **Decorative lines** made with CSS borders are ignored by assistive tools. That is good when the line is only for looks.
+- **Contrast matters.** A very light gray line on a white background may be invisible for low-vision users. Choose a color that can be seen.
+- **Right-to-left languages** such as Arabic and Hebrew work fine with `
`, because it spans the full width of its container.
+- **Do not rely on the line alone.** If a new section is important, add a heading, which also helps translation tools and search engines.
+
+## Choosing the Right Tool
+
+`
` is not the only way to separate content. Pick the tool that matches your goal.
+
+| Goal | Best choice |
+| :-- | :-- |
+| Change of topic inside a section | `
` |
+| A new major section of the page | A heading, like `` |
+| A purely visual line, such as under a title | CSS `border-bottom` |
+| Space between two blocks | CSS `margin` or `padding` |
+| Separate items in a list | Use list styling or `border` on each item |
+
+## Common Mistakes
+
+### Mistake 1: Using `
` everywhere
+
+```html
+
+
Paragraph one.
+
+Paragraph two.
+
+Paragraph three.
+
+```
+
+When every paragraph gets a line, the break loses its meaning. Save it for real changes of topic.
+
+### Mistake 2: Using it only for decoration
+
+If you only want a line under a title, a CSS `border-bottom` is the better tool. It does not say "the topic changed" when nothing changed.
+
+### Mistake 3: Using deprecated attributes
+
+```html
+
+
+
+
+
+```
+
+### Mistake 4: Writing a closing tag
+
+`` is not valid. Void elements never have a closing tag.
+
+### Mistake 5: Using it instead of headings
+
+A line does not tell users what the next section is about. If the next part has its own subject, give it a [heading](./headings).
+
+## Try It Yourself
+
+Here is a small exercise.
+
+1. Create a file called `travel-diary.html`.
+2. Write two short paragraphs about a place you visited or want to visit.
+3. Add a third paragraph about a **different day** or a **different place**.
+4. Place an `
` between the parts where the story changes.
+5. Add a CSS class that makes your line 40% wide, centered, and dotted.
+6. Remove the `
` and read the text again. Is the change still clear?
+
+
+
+
+## Quick Recap
+
+Click a question to check your answer.
+
+
+1. What does `
` represent in modern HTML?
+
+A thematic break, meaning a shift in topic between blocks of content.
+
+
+
+
+2. Does `
` need a closing tag?
+
+No. It is a void element and has no content to wrap.
+
+
+
+
+3. How should you change the width or color of a horizontal rule today?
+
+Use CSS, such as `width`, `border-top`, and `margin`. The old HTML attributes are deprecated.
+
+
+
+
+4. When is a heading better than `
`?
+
+When the next part is a new section with its own subject. A heading names that section, and a line does not.
+
+
+
+
+5. Why should you not use `
` between every paragraph?
+
+Too many breaks make each one meaningless, and screen readers may announce a separator every time.
+
+
+
+## Key Takeaways
+
+- `
` marks a **change of theme**, not just a line on the screen.
+- It is a **void, block-level** element with no closing tag.
+- Style it with **CSS**. The old attributes are deprecated.
+- Use it sparingly, and prefer headings for new sections and CSS borders for decoration.
+- Choose visible colors and think about screen readers so every learner can follow your page.
+
+Next, learn how to show importance and attention in your text with [Strong and Bold](./strong-and-bold).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/line-breaks.mdx b/tutorials/html/03-text-content/line-breaks.mdx
index 57c239bf5..c5ddb3059 100644
--- a/tutorials/html/03-text-content/line-breaks.mdx
+++ b/tutorials/html/03-text-content/line-breaks.mdx
@@ -1,15 +1,367 @@
---
-id: line-breaks
-title: "Line Breaks and Forced Spaces in HTML"
+id: html-line-breaks
+title: "HTML Line Breaks"
sidebar_label: "Line Breaks"
sidebar_position: 4
slug: /html/text-content/line-breaks
-description: "Learn when and how to use the self-closing br tag for forcing line breaks in addresses, poetry, and inline text blocks without breaking paragraphs."
+description: "Understand how the HTML br tag works, when to use a line break instead of a new paragraph, how to handle addresses and poems, and which CSS options and mistakes to know. A clear, step-by-step guide on CodeHarborHub."
keywords:
+ - HTML line break
- HTML br tag
- - line break tag
- - forced line breaks
- - inline breaks HTML
+ - HTML br vs p
+ - HTML new line
+ - HTML wbr tag
+ - HTML white-space pre-line
+ - HTML void elements
+ - HTML address formatting
+ - learn HTML line breaks
- CodeHarborHub HTML
-tags: [html, line-breaks, formatting, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, line-break, text, frontend]
+---
+
+In the last lesson you learned that pressing Enter in your code does **not** start a new line on the page. The browser ignores it. So what do you do when you really do want a new line, such as in an address or a poem, without starting a whole new paragraph?
+
+That is the job of the `
` tag. It is tiny, but understanding **when** to use it (and when not to) is what separates clean HTML from messy HTML. This lesson explains both.
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag does, in plain terms
+- What a **void element** is and why `
` has no closing tag
+- The difference between a line break and a new paragraph
+- Where line breaks make sense, and where they do not
+- Better alternatives using CSS
+- How to control where a long word may break with ` `
+
+## The Problem: Enter Does Nothing
+
+Start with the problem. Here is a short message typed on three lines.
+
+
+
+
+```html title="problem.html"
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+```
+
+
+
+
+
+<>
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+>
+
+
+
+
+
+All three lines run together into one. As you learned, the browser **collapses** line breaks in your code into a single space. To tell the browser "start a new line here", we need an actual HTML instruction.
+
+## The Solution: The `
` Tag
+
+`br` stands for **break**. Place it exactly where you want the line to end.
+
+
+
+
+```html title="solution.html"
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+```
+
+
+
+
+
+<>
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
+>
+
+
+
+
+
+Now each line stands on its own, and they all still belong to **one paragraph**.
+
+## How to Think About `
`
+
+Here is a simple way to picture it.
+
+- **Typing text** is like writing on a typewriter. The words keep flowing to the right until the paper edge, then wrap.
+- **`
`** is like pressing the carriage return on that typewriter. The next word starts at the beginning of a new line, even though you were not at the edge yet.
+
+That is all it does. It does not create a new block, and it does not add extra space. It only says, "continue from the next line."
+
+## Void Elements: Why No Closing Tag?
+
+Most HTML elements wrap around content, like `text
`. The `
` tag has **nothing to wrap**, because a line break has no content inside it. Elements like this are called **void elements**.
+
+| Wrapping element | Void element |
+| :-- | :-- |
+| `Hello
` | `
` |
+| `Hi` | `
` |
+| `Link` | `
` |
+
+You may see three ways of writing it, and all of them work in HTML.
+
+```html
+
+
+
+```
+
+:::info Which one should I use?
+In plain HTML, `
` is perfectly valid. The self-closing form `
` is required in JSX and MDX, and it is common in many style guides. Since our CodeHarborHub docs run on MDX, `
` is the safest habit.
+:::
+
+## Line Break vs New Paragraph
+
+This is the most important idea in the lesson. Both give you a new line, but they mean different things.
+
+| | `
` | `` |
+| :-- | :-- | :-- |
+| Meaning | "Same thought, next line" | "A new idea starts here" |
+| Extra space between lines | No | Yes (default margin) |
+| Structure | Stays inside one element | Creates a separate block |
+| Best for | Addresses, poems, sign-offs | Normal body text |
+
+A quick test: **if you could put a full stop and start a new idea, use a new paragraph. If the lines belong together as one unit, use a line break.**
+
+### Side by Side
+
+
+
+
+```html title="compare.html"
+
+I woke up early today.
+Then I went for a long walk.
+
+
+
+ Priya Sharma
+ 221B Green Street
+ Indore, Madhya Pradesh
+
+```
+
+
+
+
+
+<>
+I woke up early today.
+Then I went for a long walk.
+
+
+ Priya Sharma
+ 221B Green Street
+ Indore, Madhya Pradesh
+
+>
+
+
+
+
+
+Look at the gaps. The two paragraphs have space between them. The address lines sit close together because they are one block of information.
+
+## Where Line Breaks Make Sense
+
+Use `
` when the **line ending itself is part of the content**.
+
+- **Postal addresses:** name, street, and city on separate lines
+- **Poems and verses:** each line has to stay where the poet put it
+- **Sign-offs:** "Thanks," then your name on the next line
+- **Short labeled lines:** for example, contact details in a footer
+
+```html title="signoff.html"
+
+ Thanks for reading,
+ Team CodeHarborHub
+
+```
+
+## Where Line Breaks Do Not Belong
+
+### Do not use `
` to create space
+
+```html
+
+First idea.
+
+Second idea.
+```
+
+Stacking breaks is a layout trick, not meaning. It behaves differently on different screen sizes, and screen readers may announce the empty lines. Use CSS `margin` instead.
+
+```html
+
+First idea.
+Second idea.
+```
+
+### Do not use `
` to split every sentence into a paragraph
+
+If your lines are separate ideas, write separate `` elements. It makes the structure clear to search engines and assistive tools.
+
+### Do not use `
` inside lists or tables to fake layout
+
+There are proper elements for lists and tables. Reaching for `
` there is usually a sign that another tag fits better.
+
+:::warning Accessibility note
+Screen readers treat line breaks inside text as part of the reading flow. Real structure, like separate paragraphs or list items, gives users clearer signals than many `
` tags in a row.
+:::
+
+## Better Options with CSS
+
+Sometimes you have text that already contains line endings, like content from a database or a text box. Instead of adding `
` by hand, CSS can honor the line breaks for you.
+
+
+
+
+```html title="pre-line.html"
+
+
+
+Line one of my note
+Line two of my note
+Line three of my note
+
+```
+
+
+
+
+
+<>
+
+Line one of my note
+Line two of my note
+Line three of my note
+
+>
+
+
+
+
+
+`white-space: pre-line` tells the browser: "keep the line breaks I typed, but still collapse extra spaces." It is handy for user-written text.
+
+| Need | Best tool |
+| :-- | :-- |
+| One or two deliberate line endings (address, poem) | `
` |
+| Many stored line endings in existing text | CSS `white-space: pre-line` |
+| Exact spaces and line breaks, like code | The `
` element |
+| Extra space between blocks | CSS `margin` or `padding` |
+| A new idea | A new `` |
+
+## Bonus: The ` ` Tag
+
+`
` **forces** a break. Its quieter cousin, ` ` (word break opportunity), only **suggests** one. The browser breaks the line there **only if it needs to**.
+
+That helps with very long words or URLs that could overflow a small screen.
+
+```html
+
+ Read our guide at
+ https://codeharborhub. github. io/tutorial /html /text-content
+
+```
+
+On a wide screen, the text looks normal. On a narrow phone, the browser can wrap at any ` ` instead of overflowing.
+
+## Common Mistakes
+
+| Mistake | Why it is a problem | Fix |
+| :-- | :-- | :-- |
+| Writing `` | It is not valid HTML | Use `
` |
+| Many `
` in a row for spacing | Layout trick, poor accessibility | Use CSS `margin` |
+| A `
` right after every sentence | Turns body text into a choppy list | Use real paragraphs |
+| Using `
` outside any text container | Can produce unpredictable spacing | Put it inside `` or another text element |
+
+## Try It Yourself
+
+Practice with this small project.
+
+1. Create `contact-card.html`.
+2. Add an `
` that says **Contact Us**.
+3. Inside one `
`, write your name, city, and email on **three lines** using `
`.
+4. Add a **second** `
` with a normal sentence, like "We reply within a day."
+5. Compare the spacing between the two blocks. Can you explain why the gaps look different?
+
+If you can explain it, you truly understand line breaks.
+
+
+
+
+## Quick Recap
+
+Click a question to check your answer.
+
+
+1. What does `
` do?
+
+It ends the current line and starts the text on a new line, without starting a new paragraph.
+
+
+
+
+2. Why does `
` have no closing tag?
+
+It is a void element. A line break has no content to wrap, so there is nothing to close.
+
+
+
+
+3. When should you choose `` over `
`?
+
+When you are starting a new idea. Use `
` only when the lines belong together as one unit, like an address.
+
+
+
+
+4. Why is stacking several `
` tags a poor way to add space?
+
+It mixes layout with content, behaves inconsistently on different screens, and is not friendly to screen readers. CSS margin is better.
+
+
+
+
+5. What is the difference between `
` and ` `?
+
+`
` always forces a break. ` ` only allows a break if the text needs one, such as in a long word on a small screen.
+
+
+
+## Key Takeaways
+
+- Pressing Enter in your code does not create a new line on the page. Use `
` for that.
+- `
` is a **void element**. It has no content and no closing tag.
+- Use `
` when the line ending is part of the content, such as addresses, poems, and sign-offs.
+- Use `
` for new ideas, and CSS for spacing.
+- `white-space: pre-line` keeps existing line breaks, and ` ` suggests optional break points.
+
+Next, learn how to separate topics with a visual divider in [Horizontal Rule](./horizontal-rule).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/paragraphs.mdx b/tutorials/html/03-text-content/paragraphs.mdx
index 426b34192..dd10eb906 100644
--- a/tutorials/html/03-text-content/paragraphs.mdx
+++ b/tutorials/html/03-text-content/paragraphs.mdx
@@ -1,15 +1,332 @@
---
-id: paragraphs
-title: "HTML Paragraphs: Structuring Blocks of Text"
+id: html-paragraphs
+title: "HTML Paragraphs"
sidebar_label: "Paragraphs"
sidebar_position: 3
slug: /html/text-content/paragraphs
-description: "Understand the paragraph tag, block-level text rendering, browser default margins, and proper text grouping techniques in HTML."
+description: "Learn how to write paragraphs in HTML with the p tag. Understand how browsers handle spaces and line breaks, how to style paragraphs with CSS, and how to avoid common beginner mistakes, explained in simple language on CodeHarborHub."
keywords:
+ - HTML paragraphs
+ - HTML p tag
- HTML paragraph tag
- - p tag HTML
- - block level text
- - text blocks HTML
+ - HTML whitespace collapsing
+ - HTML block level elements
+ - style HTML paragraphs with CSS
+ - HTML paragraph best practices
+ - learn HTML paragraphs
- CodeHarborHub HTML
-tags: [html, paragraph, markup, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, paragraphs, text, frontend]
+---
+
+Imagine opening a book where every page is one giant wall of words. No gaps, no breaks, nothing to rest your eyes on. You would probably close it after a few lines, right?
+
+That is exactly why **paragraphs** exist. They chop your writing into small, friendly chunks so readers can breathe, follow your ideas, and keep going. In HTML, the tool for that job is the humble `
` tag, and it is one you will use in almost every page you ever build.
+
+
+
+
+## What You Will Learn
+
+By the end of this lesson, you will be able to:
+
+- Write a paragraph with the `
` tag
+- Understand why your extra spaces and blank lines seem to "disappear"
+- Style paragraphs with CSS so they are comfortable to read
+- Avoid the mistakes almost every beginner makes at least once
+
+:::info Good news
+This is one of the easiest lessons in the whole tutorial. If you can type a sentence, you can write a paragraph.
+:::
+
+## Your First Paragraph
+
+A paragraph starts with `
` and ends with `
`. Everything you put between the two tags becomes one paragraph.
+
+
+
+
+```html title="index.html"
+Hello! This is my very first paragraph.
+And this is my second one. See how it starts on a new line?
+```
+
+
+
+
+
+<>
+Hello! This is my very first paragraph.
+And this is my second one. See how it starts on a new line?
+>
+
+
+
+
+
+Notice two things. Each paragraph starts on its own line, and the browser adds a little space between them. You did not have to ask for that. The browser does it for you.
+
+## Paragraphs Are "Block" Elements
+
+In HTML, a paragraph is a **block-level element**. Picture it as a rectangular box that stretches across the full width of its container. Because of that:
+
+- A paragraph always starts on a **new line**
+- It takes up the **whole row**, even if the text is short
+- The browser adds a **margin** above and below it (about 16px by default)
+
+Think of paragraphs like boxes on a shelf. Each box gets its own row, and there is a small gap between rows.
+
+## Why Did My Spaces Disappear?
+
+Here is something that surprises almost everyone at first. Look at this code.
+
+
+
+
+```html title="spaces.html"
+
+ This paragraph has
+ lots of extra spaces
+
+
+ and blank lines.
+
+```
+
+
+
+
+
+<>
+
+ This paragraph has
+ lots of extra spaces
+
+
+ and blank lines.
+
+>
+
+
+
+
+
+You typed a bunch of spaces and blank lines, but the browser shows one tidy line. That is not a bug. It is called **whitespace collapsing**. The browser squishes any run of spaces, tabs, and line breaks into a single space.
+
+Why does it work this way? So you can format your code however you like, with indentation and line wraps, without changing what visitors see.
+
+:::tip Want to keep your spacing?
+If you truly need spaces and line breaks preserved, you have two options. Use `
` for a line break (next lesson), or use the `` tag for preformatted text.
+:::
+
+## Long Text? Break It Up
+
+Compare these two versions of the same text. Which one would you rather read?
+
+
+
+
+```html
+
+ HTML is the skeleton of every web page. It tells the browser what is a title,
+ what is a paragraph, and what is a link. CSS then adds colors and layout, and
+ JavaScript brings the page to life with interaction. Learning all three takes
+ time, but starting with HTML gives you a strong base for everything else.
+
+```
+
+
+
+
+```html
+
+ HTML is the skeleton of every web page. It tells the browser what is a title,
+ what is a paragraph, and what is a link.
+
+
+ CSS then adds colors and layout, and JavaScript brings the page to life with
+ interaction.
+
+
+ Learning all three takes time, but starting with HTML gives you a strong base
+ for everything else.
+
+```
+
+
+
+
+A good rule of thumb: **one paragraph, one idea**. When your idea changes, start a new paragraph.
+
+## Styling Paragraphs with CSS
+
+The default look works, but a few small CSS tweaks can make your text much nicer to read.
+
+
+
+
+```html title="styled-paragraph.html"
+
+
+
+ Comfortable text is not an accident. A little extra line height and a limited
+ width make long paragraphs far easier on the eyes.
+
+```
+
+
+
+
+
+<>
+
+ Comfortable text is not an accident. A little extra line height and a limited
+ width make long paragraphs far easier on the eyes.
+
+>
+
+
+
+
+
+Here is what each property does:
+
+| CSS property | What it does | Friendly tip |
+| :-- | :-- | :-- |
+| `font-size` | Changes the text size | Keep body text at 16px or larger |
+| `line-height` | Sets the space between lines | Try 1.5 to 1.8 for easy reading |
+| `max-width` | Limits how wide the text can get | Around `60ch` to `75ch` works well |
+| `color` | Sets the text color | Make sure it contrasts with the background |
+| `text-align` | Aligns the text | Left-aligned is easiest for most readers |
+| `margin` | Changes the gap between paragraphs | Use `margin-bottom` for even spacing |
+
+## Mistakes Everyone Makes (and Easy Fixes)
+
+Do not worry if you have already done these. Every developer has.
+
+### Mistake 1: Using empty paragraphs for spacing
+
+```html
+
+First idea.
+
+
+Second idea.
+```
+
+Empty `` tags add noise, not meaning. If you want more space, use CSS `margin` or `padding` instead.
+
+### Mistake 2: Putting one paragraph inside another
+
+```html
+
+
+ Outer paragraph
+
Inner paragraph
+
+```
+
+Paragraphs cannot contain other paragraphs. The browser will quietly close the first one as soon as it sees the second, and your layout will not match what you wrote.
+
+### Mistake 3: Putting block elements inside a paragraph
+
+A `
` | Inside the page content | Names the page for the reader |
-## A Note on Subheadings and Taglines
+They are often similar, but they do not have to match exactly.
-Sometimes a heading has a subtitle or tagline, like "The Complete Guide" beneath "Learning HTML." A subtitle is not a new section, so it should **not** be another heading level. Use a paragraph instead:
+## Practice
-```html
-Learning HTML
-
The complete beginner's guide to building web pages
-``` +Try this in your editor. -HTML also has an `` element for grouping a heading with its subtitle, but the simple heading-plus-paragraph pattern above works everywhere and is perfectly fine for beginners. +1. Create a file called `recipe.html`. +2. Add an `` with the name of a dish.
+3. Add two `` headings: **Ingredients** and **Steps**.
+4. Under **Steps**, add an `` for each stage, such as **Prepare** and **Cook**.
+5. Add a short `
` for each stage, such as **Prepare** and **Cook**. +5. Add a short `
` under every heading.
+6. Read only the headings. Does the outline tell the story of the recipe?
Contact Us
-## Writing Great Headings
-
-Good headings are a writing skill as much as a technical one. Keep these habits in mind:
-
-- **Be descriptive.** "Getting Started with Git" beats "Getting Started."
-- **Be concise.** A heading is a label, not a sentence from the middle of a paragraph.
-- **Be unique.** Avoid repeating the same heading text many times on one page.
-- **Be parallel.** If your headings are "Installing Git" and "Configuring Git," keep that pattern instead of switching to "How Do I Make Commits?"
-- **Never leave one empty.** An empty heading confuses assistive technology and adds nothing.
-
-## Common Heading Mistakes
-
-1. Choosing a heading level for its size
-
-```html
-
-Our Company History
-
-
-Our Company History
-```
-
-2. Using bold paragraphs instead of headings
-
-```html
-
-Contact Us
-```
-
-3. Skipping heading levels
-
-Jumping from `` straight to `
` breaks the outline. Move down one level at a time.
-
-
4. Having no h1, or an h1 that does not match the page
-
-Every page should have a clear `` that describes its main topic. A page whose first heading is an `
`, or whose `
` is only the site logo text on every page, loses much of the structure benefit.
-
-
5. Using headings for layout or spacing
-
-Do not wrap unrelated text in a heading just to push content down or make it stand out. Use CSS margins and padding for spacing.
-
-
My Travel Blog
-Day 1: Paris
-Morning
-Afternoon
-Day 2: Rome
-Evening
-``` - -π Click to reveal the solution
- -```html title="fixed-headings.html" -My Travel Blog
-Day 1: Paris
-Morning
-Afternoon
-Day 2: Rome
-Evening
-``` - -1. The main title "My Travel Blog" was an ``, but it should be the page's ``.
-2. "Day 1: Paris" was the ``, but it is a major section, so it becomes an ``.
-3. "Morning" and "Afternoon" jumped to ``, skipping ``. They become ``.
-4. "Evening" was a styled paragraph faking a heading, so it became a real ``.
-
-
`, but it is a major section, so it becomes an ``.
-3. "Morning" and "Afternoon" jumped to ``, skipping ``. They become ``.
-4. "Evening" was a styled paragraph faking a heading, so it became a real ``.
-
-
`, skipping ``. They become ``.
-4. "Evening" was a styled paragraph faking a heading, so it became a real ``.
-
-
`.
-4. "Evening" was a styled paragraph faking a heading, so it became a real ``.
-
-
` to ``**, forming the **outline** of your page.
-- Use **one ``** per page as the main title, and go down **one level at a time**.
-- Choose a heading level for **meaning and structure**, never for size. Use **CSS** to change how it looks.
-- Good headings help **SEO** by describing your page's topics clearly.
-- Real headings power **accessibility**, letting screen reader users skim and jump between sections.
-- Headings can contain **inline elements**, and combined with `id`, they can be **link targets**.
-- A subtitle is usually a **paragraph**, not another heading level.
-
-## Frequently Asked Questions
+Click a question to reveal the answer.
- How many h1 tags should a page have?
+1. How many heading levels does HTML have?
-HTML allows more than one, but using a single `` per page is the widely recommended practice. It keeps the page's main topic clear for visitors, search engines, and assistive technology.
+Six, from `` to ``.
- What is the difference between h1 and title?
+2. How many `` elements should a page normally have?
-The `` element lives in the `` and appears in the browser tab and search results. The `` lives in the `` and is the main visible heading of the page content. They are usually related, but they are separate elements.
+One. It is the main title of the page.
- Can I skip heading levels, like going from h2 to h4?
+3. Why should you not use `` just to get smaller text?
-You should avoid it. Skipping levels breaks the logical outline and can confuse screen reader users. Go down one level at a time, though you may jump back up to a higher level when starting a new section.
+The heading level shows rank in the outline, not size. Use CSS to change how big text looks.
- How do I make a heading smaller without changing its level?
+4. Which two groups of users benefit most from a correct heading outline?
-Use CSS, for example `h2 { font-size: 1.2rem; }`. The heading level describes structure, while CSS controls appearance.
+Screen reader users, who navigate by headings, and search engines, which use headings to understand the page.
- Do headings affect SEO?
+5. What is the difference between `` and ``?
-Yes. Search engines use headings to understand the structure and topics of a page. Clear, descriptive headings that reflect real content help, but keyword stuffing does not.
+`` shows in the browser tab and search results. `` shows inside the page as its visible title.
-
- Should I use h5 and h6?
-
-Rarely. Most pages are well served by h1 through h3, and sometimes h4. If you find yourself needing h5 or h6 often, consider whether your content could be split into separate sections or pages.
+## Key Takeaways
-
+- HTML has six heading levels, `` (most important) to `` (least important).
+- Headings build the **outline** of your page.
+- Use one `` and never skip levels.
+- Pick headings for **meaning**, and use CSS for **appearance**.
+- Good headings help SEO, accessibility, and readability.
-## Test Your Understanding
-
-1. What is the difference in meaning between `` and ``?
-2. Why is it a bad idea to choose `` just because it looks the right size?
-3. What does it mean to "skip a heading level," and why should you avoid it?
-4. How does a screen reader user benefit from real headings?
-5. Where should a subtitle like "The complete beginner's guide" go?
-
-
-
\ No newline at end of file
+Next, learn how to write body text in [Paragraphs](./paragraphs).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/horizontal-rule.mdx b/tutorials/html/03-text-content/horizontal-rule.mdx
index 8c9aa1236..f41fbd466 100644
--- a/tutorials/html/03-text-content/horizontal-rule.mdx
+++ b/tutorials/html/03-text-content/horizontal-rule.mdx
@@ -1,15 +1,339 @@
---
-id: horizontal-rule
-title: "Horizontal Rules: The hr Tag for Thematic Breaks"
+id: html-horizontal-rule
+title: "HTML Horizontal Rule"
sidebar_label: "Horizontal Rule"
sidebar_position: 5
slug: /html/text-content/horizontal-rule
-description: "Explore the hr element in HTML to create thematic breaks, section dividers, and visual content shifts across web pages."
+description: "Learn how to use the HTML hr tag to mark a thematic break between topics. Understand its meaning, default look, how to style it with CSS, accessibility tips, and common mistakes, explained clearly on CodeHarborHub."
keywords:
+ - HTML horizontal rule
- HTML hr tag
- - horizontal rule
- - thematic break HTML
- - section divider HTML
+ - HTML thematic break
+ - style hr with CSS
+ - HTML divider line
+ - HTML hr accessibility
+ - HTML void elements
+ - HTML separator
+ - learn HTML hr
- CodeHarborHub HTML
-tags: [html, hr-tag, layout, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, horizontal-rule, text, frontend]
+---
+
+Think about reading a story. Suddenly the writer leaves a small gap, maybe adds a line or a few stars, and starts again in a new place or at a new time. You feel the change right away. Nobody had to explain it.
+
+HTML has a tool for exactly this moment: the **horizontal rule**, written as `
`. It draws a line across the page, but its real job is not decoration. It tells the reader, "The topic is changing here."
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag is and what it means
+- When a horizontal rule is the right choice
+- How to style it with CSS, since old HTML attributes are outdated
+- How screen readers treat it
+- Common mistakes, and better alternatives
+
+## The Basics
+
+The `
` tag creates a **thematic break** between two blocks of content. It is a **void element**, which means it has no content inside and no closing tag. (You met void elements in the [Line Breaks](./line-breaks) lesson.)
+
+
+
+
+```html title="index.html"
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+```
+
+
+
+
+
+<>
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+>
+
+
+
+
+
+The browser draws a thin line across the full width of its container, with a little space above and below. It is a block-level element, so it always sits on its own row.
+
+:::info Two ways to write it
+In plain HTML, both `
` and `
` work. In MDX and JSX, use `
`, because unclosed tags cause errors there.
+:::
+
+## What Does "Thematic Break" Mean?
+
+In older HTML, `
` meant "horizontal **rule**", so people thought of it only as a line. In modern HTML, the meaning is a **shift in theme** at the paragraph level.
+
+Here is the difference in simple terms.
+
+| Old idea | Modern idea |
+| :-- | :-- |
+| "Draw a line here." | "The subject changes here." |
+| About appearance | About meaning |
+| Visual decoration | Content structure |
+
+That is why the line you see is only the **default look**. The meaning stays even if you restyle it.
+
+## When to Use `
`
+
+Use it when there is a real change of topic inside a section, but the change is too small for a new heading.
+
+- **A scene change** in a story
+- **A shift in subject** between two paragraphs
+- **A separator** between a main article and its notes or sign-off
+- **A pause** between a question and its long answer
+
+
+
+
+```html title="story.html"
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+```
+
+
+
+
+
+<>
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+>
+
+
+
+
+
+A quick test: **if you removed the line, would the change of topic still be clear?** If yes, you probably do not need `
`. If a reader might get confused, it helps.
+
+## Old Attributes Are Gone: Use CSS
+
+Old tutorials show attributes like `width`, `size`, `align`, and `noshade` on `
`. These are **deprecated**. They still work in some browsers, but you should not use them. CSS gives you full control instead.
+
+| Old attribute | Modern CSS |
+| :-- | :-- |
+| `width="50%"` | `width: 50%;` |
+| `size="5"` | `border-width` or `height` |
+| `align="center"` | `margin-inline: auto;` |
+| `noshade` | `border-style` and `background` |
+
+### A Clean Custom Line
+
+
+
+
+```html title="styled-hr.html"
+
+
+First topic.
+
+Second topic.
+```
+
+
+
+
+
+<>
+First topic.
+
+Second topic.
+>
+
+
+
+
+
+### A Few More Styles
+
+
+
+
+```css
+hr.dashed {
+ border: none;
+ border-top: 2px dashed #64748b;
+}
+```
+
+
+
+
+```css
+hr.fade {
+ height: 2px;
+ border: none;
+ background: linear-gradient(to right, transparent, #2563eb, transparent);
+}
+```
+
+
+
+
+```css
+hr.dotted {
+ border: none;
+ border-top: 4px dotted #94a3b8;
+ width: 30%;
+ margin-inline: auto;
+}
+```
+
+
+
+
+:::tip Reset first
+Browsers add their own border style and margin to `
`. Setting `border: none` first, then adding the style you want, gives you a predictable result in every browser.
+:::
+
+## Accessibility and Global Readers
+
+Not everyone sees the page in the same way, so it helps to know what happens behind the scenes.
+
+- **Screen readers** usually announce `
` as a **separator**. Some readers skip it, and others say the word. This is why you should use it only when the break is meaningful.
+- **Decorative lines** made with CSS borders are ignored by assistive tools. That is good when the line is only for looks.
+- **Contrast matters.** A very light gray line on a white background may be invisible for low-vision users. Choose a color that can be seen.
+- **Right-to-left languages** such as Arabic and Hebrew work fine with `
`, because it spans the full width of its container.
+- **Do not rely on the line alone.** If a new section is important, add a heading, which also helps translation tools and search engines.
+
+## Choosing the Right Tool
+
+`
` is not the only way to separate content. Pick the tool that matches your goal.
+
+| Goal | Best choice |
+| :-- | :-- |
+| Change of topic inside a section | `
` |
+| A new major section of the page | A heading, like `` |
+| A purely visual line, such as under a title | CSS `border-bottom` |
+| Space between two blocks | CSS `margin` or `padding` |
+| Separate items in a list | Use list styling or `border` on each item |
+
+## Common Mistakes
+
+### Mistake 1: Using `
` everywhere
+
+```html
+
+
`** per page as the main title, and go down **one level at a time**.
-- Choose a heading level for **meaning and structure**, never for size. Use **CSS** to change how it looks.
-- Good headings help **SEO** by describing your page's topics clearly.
-- Real headings power **accessibility**, letting screen reader users skim and jump between sections.
-- Headings can contain **inline elements**, and combined with `id`, they can be **link targets**.
-- A subtitle is usually a **paragraph**, not another heading level.
-
-## Frequently Asked Questions
+Click a question to reveal the answer.
- How many h1 tags should a page have?
+1. How many heading levels does HTML have?
-HTML allows more than one, but using a single `` per page is the widely recommended practice. It keeps the page's main topic clear for visitors, search engines, and assistive technology.
+Six, from `` to ``.
- What is the difference between h1 and title?
+2. How many `` elements should a page normally have?
-The `` element lives in the `` and appears in the browser tab and search results. The `` lives in the `` and is the main visible heading of the page content. They are usually related, but they are separate elements.
+One. It is the main title of the page.
- Can I skip heading levels, like going from h2 to h4?
+3. Why should you not use `` just to get smaller text?
-You should avoid it. Skipping levels breaks the logical outline and can confuse screen reader users. Go down one level at a time, though you may jump back up to a higher level when starting a new section.
+The heading level shows rank in the outline, not size. Use CSS to change how big text looks.
- How do I make a heading smaller without changing its level?
+4. Which two groups of users benefit most from a correct heading outline?
-Use CSS, for example `h2 { font-size: 1.2rem; }`. The heading level describes structure, while CSS controls appearance.
+Screen reader users, who navigate by headings, and search engines, which use headings to understand the page.
- Do headings affect SEO?
+5. What is the difference between `` and ``?
-Yes. Search engines use headings to understand the structure and topics of a page. Clear, descriptive headings that reflect real content help, but keyword stuffing does not.
+`` shows in the browser tab and search results. `` shows inside the page as its visible title.
-
- Should I use h5 and h6?
-
-Rarely. Most pages are well served by h1 through h3, and sometimes h4. If you find yourself needing h5 or h6 often, consider whether your content could be split into separate sections or pages.
+## Key Takeaways
-
+- HTML has six heading levels, `` (most important) to `` (least important).
+- Headings build the **outline** of your page.
+- Use one `` and never skip levels.
+- Pick headings for **meaning**, and use CSS for **appearance**.
+- Good headings help SEO, accessibility, and readability.
-## Test Your Understanding
-
-1. What is the difference in meaning between `` and ``?
-2. Why is it a bad idea to choose `` just because it looks the right size?
-3. What does it mean to "skip a heading level," and why should you avoid it?
-4. How does a screen reader user benefit from real headings?
-5. Where should a subtitle like "The complete beginner's guide" go?
-
-
-
\ No newline at end of file
+Next, learn how to write body text in [Paragraphs](./paragraphs).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/horizontal-rule.mdx b/tutorials/html/03-text-content/horizontal-rule.mdx
index 8c9aa1236..f41fbd466 100644
--- a/tutorials/html/03-text-content/horizontal-rule.mdx
+++ b/tutorials/html/03-text-content/horizontal-rule.mdx
@@ -1,15 +1,339 @@
---
-id: horizontal-rule
-title: "Horizontal Rules: The hr Tag for Thematic Breaks"
+id: html-horizontal-rule
+title: "HTML Horizontal Rule"
sidebar_label: "Horizontal Rule"
sidebar_position: 5
slug: /html/text-content/horizontal-rule
-description: "Explore the hr element in HTML to create thematic breaks, section dividers, and visual content shifts across web pages."
+description: "Learn how to use the HTML hr tag to mark a thematic break between topics. Understand its meaning, default look, how to style it with CSS, accessibility tips, and common mistakes, explained clearly on CodeHarborHub."
keywords:
+ - HTML horizontal rule
- HTML hr tag
- - horizontal rule
- - thematic break HTML
- - section divider HTML
+ - HTML thematic break
+ - style hr with CSS
+ - HTML divider line
+ - HTML hr accessibility
+ - HTML void elements
+ - HTML separator
+ - learn HTML hr
- CodeHarborHub HTML
-tags: [html, hr-tag, layout, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, horizontal-rule, text, frontend]
+---
+
+Think about reading a story. Suddenly the writer leaves a small gap, maybe adds a line or a few stars, and starts again in a new place or at a new time. You feel the change right away. Nobody had to explain it.
+
+HTML has a tool for exactly this moment: the **horizontal rule**, written as `
`. It draws a line across the page, but its real job is not decoration. It tells the reader, "The topic is changing here."
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag is and what it means
+- When a horizontal rule is the right choice
+- How to style it with CSS, since old HTML attributes are outdated
+- How screen readers treat it
+- Common mistakes, and better alternatives
+
+## The Basics
+
+The `
` tag creates a **thematic break** between two blocks of content. It is a **void element**, which means it has no content inside and no closing tag. (You met void elements in the [Line Breaks](./line-breaks) lesson.)
+
+
+
+
+```html title="index.html"
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+```
+
+
+
+
+
+<>
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+>
+
+
+
+
+
+The browser draws a thin line across the full width of its container, with a little space above and below. It is a block-level element, so it always sits on its own row.
+
+:::info Two ways to write it
+In plain HTML, both `
` and `
` work. In MDX and JSX, use `
`, because unclosed tags cause errors there.
+:::
+
+## What Does "Thematic Break" Mean?
+
+In older HTML, `
` meant "horizontal **rule**", so people thought of it only as a line. In modern HTML, the meaning is a **shift in theme** at the paragraph level.
+
+Here is the difference in simple terms.
+
+| Old idea | Modern idea |
+| :-- | :-- |
+| "Draw a line here." | "The subject changes here." |
+| About appearance | About meaning |
+| Visual decoration | Content structure |
+
+That is why the line you see is only the **default look**. The meaning stays even if you restyle it.
+
+## When to Use `
`
+
+Use it when there is a real change of topic inside a section, but the change is too small for a new heading.
+
+- **A scene change** in a story
+- **A shift in subject** between two paragraphs
+- **A separator** between a main article and its notes or sign-off
+- **A pause** between a question and its long answer
+
+
+
+
+```html title="story.html"
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+```
+
+
+
+
+
+<>
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+>
+
+
+
+
+
+A quick test: **if you removed the line, would the change of topic still be clear?** If yes, you probably do not need `
`. If a reader might get confused, it helps.
+
+## Old Attributes Are Gone: Use CSS
+
+Old tutorials show attributes like `width`, `size`, `align`, and `noshade` on `
`. These are **deprecated**. They still work in some browsers, but you should not use them. CSS gives you full control instead.
+
+| Old attribute | Modern CSS |
+| :-- | :-- |
+| `width="50%"` | `width: 50%;` |
+| `size="5"` | `border-width` or `height` |
+| `align="center"` | `margin-inline: auto;` |
+| `noshade` | `border-style` and `background` |
+
+### A Clean Custom Line
+
+
+
+
+```html title="styled-hr.html"
+
+
+First topic.
+
+Second topic.
+```
+
+
+
+
+
+<>
+First topic.
+
+Second topic.
+>
+
+
+
+
+
+### A Few More Styles
+
+
+
+
+```css
+hr.dashed {
+ border: none;
+ border-top: 2px dashed #64748b;
+}
+```
+
+
+
+
+```css
+hr.fade {
+ height: 2px;
+ border: none;
+ background: linear-gradient(to right, transparent, #2563eb, transparent);
+}
+```
+
+
+
+
+```css
+hr.dotted {
+ border: none;
+ border-top: 4px dotted #94a3b8;
+ width: 30%;
+ margin-inline: auto;
+}
+```
+
+
+
+
+:::tip Reset first
+Browsers add their own border style and margin to `
`. Setting `border: none` first, then adding the style you want, gives you a predictable result in every browser.
+:::
+
+## Accessibility and Global Readers
+
+Not everyone sees the page in the same way, so it helps to know what happens behind the scenes.
+
+- **Screen readers** usually announce `
` as a **separator**. Some readers skip it, and others say the word. This is why you should use it only when the break is meaningful.
+- **Decorative lines** made with CSS borders are ignored by assistive tools. That is good when the line is only for looks.
+- **Contrast matters.** A very light gray line on a white background may be invisible for low-vision users. Choose a color that can be seen.
+- **Right-to-left languages** such as Arabic and Hebrew work fine with `
`, because it spans the full width of its container.
+- **Do not rely on the line alone.** If a new section is important, add a heading, which also helps translation tools and search engines.
+
+## Choosing the Right Tool
+
+`
` is not the only way to separate content. Pick the tool that matches your goal.
+
+| Goal | Best choice |
+| :-- | :-- |
+| Change of topic inside a section | `
` |
+| A new major section of the page | A heading, like `` |
+| A purely visual line, such as under a title | CSS `border-bottom` |
+| Space between two blocks | CSS `margin` or `padding` |
+| Separate items in a list | Use list styling or `border` on each item |
+
+## Common Mistakes
+
+### Mistake 1: Using `
` everywhere
+
+```html
+
+
How many h1 tags should a page have?
+1. How many heading levels does HTML have?
-HTML allows more than one, but using a single `` per page is the widely recommended practice. It keeps the page's main topic clear for visitors, search engines, and assistive technology.
+Six, from `` to ``.
`.
What is the difference between h1 and title?
+2. How many `` elements should a page normally have?
-The `` lives in the `` and is the main visible heading of the page content. They are usually related, but they are separate elements. +One. It is the main title of the page.
Can I skip heading levels, like going from h2 to h4?
+3. Why should you not use `` just to get smaller text?
-You should avoid it. Skipping levels breaks the logical outline and can confuse screen reader users. Go down one level at a time, though you may jump back up to a higher level when starting a new section.
+The heading level shows rank in the outline, not size. Use CSS to change how big text looks.
How do I make a heading smaller without changing its level?
+4. Which two groups of users benefit most from a correct heading outline?
-Use CSS, for example `h2 { font-size: 1.2rem; }`. The heading level describes structure, while CSS controls appearance. +Screen reader users, who navigate by headings, and search engines, which use headings to understand the page.Do headings affect SEO?
+5. What is the difference between `` and ``?
-Yes. Search engines use headings to understand the structure and topics of a page. Clear, descriptive headings that reflect real content help, but keyword stuffing does not.
+``?
` shows inside the page as its visible title.
Should I use h5 and h6?
- -Rarely. Most pages are well served by h1 through h3, and sometimes h4. If you find yourself needing h5 or h6 often, consider whether your content could be split into separate sections or pages. +## Key Takeaways -` (least important).
+- Headings build the **outline** of your page.
+- Use one `` and never skip levels.
+- Pick headings for **meaning**, and use CSS for **appearance**.
+- Good headings help SEO, accessibility, and readability.
-## Test Your Understanding
-
-1. What is the difference in meaning between `` and ``?
-2. Why is it a bad idea to choose `` just because it looks the right size?
-3. What does it mean to "skip a heading level," and why should you avoid it?
-4. How does a screen reader user benefit from real headings?
-5. Where should a subtitle like "The complete beginner's guide" go?
-
-
-
\ No newline at end of file
+Next, learn how to write body text in [Paragraphs](./paragraphs).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/horizontal-rule.mdx b/tutorials/html/03-text-content/horizontal-rule.mdx
index 8c9aa1236..f41fbd466 100644
--- a/tutorials/html/03-text-content/horizontal-rule.mdx
+++ b/tutorials/html/03-text-content/horizontal-rule.mdx
@@ -1,15 +1,339 @@
---
-id: horizontal-rule
-title: "Horizontal Rules: The hr Tag for Thematic Breaks"
+id: html-horizontal-rule
+title: "HTML Horizontal Rule"
sidebar_label: "Horizontal Rule"
sidebar_position: 5
slug: /html/text-content/horizontal-rule
-description: "Explore the hr element in HTML to create thematic breaks, section dividers, and visual content shifts across web pages."
+description: "Learn how to use the HTML hr tag to mark a thematic break between topics. Understand its meaning, default look, how to style it with CSS, accessibility tips, and common mistakes, explained clearly on CodeHarborHub."
keywords:
+ - HTML horizontal rule
- HTML hr tag
- - horizontal rule
- - thematic break HTML
- - section divider HTML
+ - HTML thematic break
+ - style hr with CSS
+ - HTML divider line
+ - HTML hr accessibility
+ - HTML void elements
+ - HTML separator
+ - learn HTML hr
- CodeHarborHub HTML
-tags: [html, hr-tag, layout, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, horizontal-rule, text, frontend]
+---
+
+Think about reading a story. Suddenly the writer leaves a small gap, maybe adds a line or a few stars, and starts again in a new place or at a new time. You feel the change right away. Nobody had to explain it.
+
+HTML has a tool for exactly this moment: the **horizontal rule**, written as `
`. It draws a line across the page, but its real job is not decoration. It tells the reader, "The topic is changing here."
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag is and what it means
+- When a horizontal rule is the right choice
+- How to style it with CSS, since old HTML attributes are outdated
+- How screen readers treat it
+- Common mistakes, and better alternatives
+
+## The Basics
+
+The `
` tag creates a **thematic break** between two blocks of content. It is a **void element**, which means it has no content inside and no closing tag. (You met void elements in the [Line Breaks](./line-breaks) lesson.)
+
+
+
+
+```html title="index.html"
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+```
+
+
+
+
+
+<>
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+>
+
+
+
+
+
+The browser draws a thin line across the full width of its container, with a little space above and below. It is a block-level element, so it always sits on its own row.
+
+:::info Two ways to write it
+In plain HTML, both `
` and `
` work. In MDX and JSX, use `
`, because unclosed tags cause errors there.
+:::
+
+## What Does "Thematic Break" Mean?
+
+In older HTML, `
` meant "horizontal **rule**", so people thought of it only as a line. In modern HTML, the meaning is a **shift in theme** at the paragraph level.
+
+Here is the difference in simple terms.
+
+| Old idea | Modern idea |
+| :-- | :-- |
+| "Draw a line here." | "The subject changes here." |
+| About appearance | About meaning |
+| Visual decoration | Content structure |
+
+That is why the line you see is only the **default look**. The meaning stays even if you restyle it.
+
+## When to Use `
`
+
+Use it when there is a real change of topic inside a section, but the change is too small for a new heading.
+
+- **A scene change** in a story
+- **A shift in subject** between two paragraphs
+- **A separator** between a main article and its notes or sign-off
+- **A pause** between a question and its long answer
+
+
+
+
+```html title="story.html"
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+```
+
+
+
+
+
+<>
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+>
+
+
+
+
+
+A quick test: **if you removed the line, would the change of topic still be clear?** If yes, you probably do not need `
`. If a reader might get confused, it helps.
+
+## Old Attributes Are Gone: Use CSS
+
+Old tutorials show attributes like `width`, `size`, `align`, and `noshade` on `
`. These are **deprecated**. They still work in some browsers, but you should not use them. CSS gives you full control instead.
+
+| Old attribute | Modern CSS |
+| :-- | :-- |
+| `width="50%"` | `width: 50%;` |
+| `size="5"` | `border-width` or `height` |
+| `align="center"` | `margin-inline: auto;` |
+| `noshade` | `border-style` and `background` |
+
+### A Clean Custom Line
+
+
+
+
+```html title="styled-hr.html"
+
+
+First topic.
+
+Second topic.
+```
+
+
+
+
+
+<>
+First topic.
+
+Second topic.
+>
+
+
+
+
+
+### A Few More Styles
+
+
+
+
+```css
+hr.dashed {
+ border: none;
+ border-top: 2px dashed #64748b;
+}
+```
+
+
+
+
+```css
+hr.fade {
+ height: 2px;
+ border: none;
+ background: linear-gradient(to right, transparent, #2563eb, transparent);
+}
+```
+
+
+
+
+```css
+hr.dotted {
+ border: none;
+ border-top: 4px dotted #94a3b8;
+ width: 30%;
+ margin-inline: auto;
+}
+```
+
+
+
+
+:::tip Reset first
+Browsers add their own border style and margin to `
`. Setting `border: none` first, then adding the style you want, gives you a predictable result in every browser.
+:::
+
+## Accessibility and Global Readers
+
+Not everyone sees the page in the same way, so it helps to know what happens behind the scenes.
+
+- **Screen readers** usually announce `
` as a **separator**. Some readers skip it, and others say the word. This is why you should use it only when the break is meaningful.
+- **Decorative lines** made with CSS borders are ignored by assistive tools. That is good when the line is only for looks.
+- **Contrast matters.** A very light gray line on a white background may be invisible for low-vision users. Choose a color that can be seen.
+- **Right-to-left languages** such as Arabic and Hebrew work fine with `
`, because it spans the full width of its container.
+- **Do not rely on the line alone.** If a new section is important, add a heading, which also helps translation tools and search engines.
+
+## Choosing the Right Tool
+
+`
` is not the only way to separate content. Pick the tool that matches your goal.
+
+| Goal | Best choice |
+| :-- | :-- |
+| Change of topic inside a section | `
` |
+| A new major section of the page | A heading, like `` |
+| A purely visual line, such as under a title | CSS `border-bottom` |
+| Space between two blocks | CSS `margin` or `padding` |
+| Separate items in a list | Use list styling or `border` on each item |
+
+## Common Mistakes
+
+### Mistake 1: Using `
` everywhere
+
+```html
+
+
` and ``?
-2. Why is it a bad idea to choose `` just because it looks the right size?
-3. What does it mean to "skip a heading level," and why should you avoid it?
-4. How does a screen reader user benefit from real headings?
-5. Where should a subtitle like "The complete beginner's guide" go?
-
-
-
\ No newline at end of file
+Next, learn how to write body text in [Paragraphs](./paragraphs).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/horizontal-rule.mdx b/tutorials/html/03-text-content/horizontal-rule.mdx
index 8c9aa1236..f41fbd466 100644
--- a/tutorials/html/03-text-content/horizontal-rule.mdx
+++ b/tutorials/html/03-text-content/horizontal-rule.mdx
@@ -1,15 +1,339 @@
---
-id: horizontal-rule
-title: "Horizontal Rules: The hr Tag for Thematic Breaks"
+id: html-horizontal-rule
+title: "HTML Horizontal Rule"
sidebar_label: "Horizontal Rule"
sidebar_position: 5
slug: /html/text-content/horizontal-rule
-description: "Explore the hr element in HTML to create thematic breaks, section dividers, and visual content shifts across web pages."
+description: "Learn how to use the HTML hr tag to mark a thematic break between topics. Understand its meaning, default look, how to style it with CSS, accessibility tips, and common mistakes, explained clearly on CodeHarborHub."
keywords:
+ - HTML horizontal rule
- HTML hr tag
- - horizontal rule
- - thematic break HTML
- - section divider HTML
+ - HTML thematic break
+ - style hr with CSS
+ - HTML divider line
+ - HTML hr accessibility
+ - HTML void elements
+ - HTML separator
+ - learn HTML hr
- CodeHarborHub HTML
-tags: [html, hr-tag, layout, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, horizontal-rule, text, frontend]
+---
+
+Think about reading a story. Suddenly the writer leaves a small gap, maybe adds a line or a few stars, and starts again in a new place or at a new time. You feel the change right away. Nobody had to explain it.
+
+HTML has a tool for exactly this moment: the **horizontal rule**, written as `
`. It draws a line across the page, but its real job is not decoration. It tells the reader, "The topic is changing here."
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag is and what it means
+- When a horizontal rule is the right choice
+- How to style it with CSS, since old HTML attributes are outdated
+- How screen readers treat it
+- Common mistakes, and better alternatives
+
+## The Basics
+
+The `
` tag creates a **thematic break** between two blocks of content. It is a **void element**, which means it has no content inside and no closing tag. (You met void elements in the [Line Breaks](./line-breaks) lesson.)
+
+
+
+
+```html title="index.html"
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+```
+
+
+
+
+
+<>
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+>
+
+
+
+
+
+The browser draws a thin line across the full width of its container, with a little space above and below. It is a block-level element, so it always sits on its own row.
+
+:::info Two ways to write it
+In plain HTML, both `
` and `
` work. In MDX and JSX, use `
`, because unclosed tags cause errors there.
+:::
+
+## What Does "Thematic Break" Mean?
+
+In older HTML, `
` meant "horizontal **rule**", so people thought of it only as a line. In modern HTML, the meaning is a **shift in theme** at the paragraph level.
+
+Here is the difference in simple terms.
+
+| Old idea | Modern idea |
+| :-- | :-- |
+| "Draw a line here." | "The subject changes here." |
+| About appearance | About meaning |
+| Visual decoration | Content structure |
+
+That is why the line you see is only the **default look**. The meaning stays even if you restyle it.
+
+## When to Use `
`
+
+Use it when there is a real change of topic inside a section, but the change is too small for a new heading.
+
+- **A scene change** in a story
+- **A shift in subject** between two paragraphs
+- **A separator** between a main article and its notes or sign-off
+- **A pause** between a question and its long answer
+
+
+
+
+```html title="story.html"
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+```
+
+
+
+
+
+<>
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+>
+
+
+
+
+
+A quick test: **if you removed the line, would the change of topic still be clear?** If yes, you probably do not need `
`. If a reader might get confused, it helps.
+
+## Old Attributes Are Gone: Use CSS
+
+Old tutorials show attributes like `width`, `size`, `align`, and `noshade` on `
`. These are **deprecated**. They still work in some browsers, but you should not use them. CSS gives you full control instead.
+
+| Old attribute | Modern CSS |
+| :-- | :-- |
+| `width="50%"` | `width: 50%;` |
+| `size="5"` | `border-width` or `height` |
+| `align="center"` | `margin-inline: auto;` |
+| `noshade` | `border-style` and `background` |
+
+### A Clean Custom Line
+
+
+
+
+```html title="styled-hr.html"
+
+
+First topic.
+
+Second topic.
+```
+
+
+
+
+
+<>
+First topic.
+
+Second topic.
+>
+
+
+
+
+
+### A Few More Styles
+
+
+
+
+```css
+hr.dashed {
+ border: none;
+ border-top: 2px dashed #64748b;
+}
+```
+
+
+
+
+```css
+hr.fade {
+ height: 2px;
+ border: none;
+ background: linear-gradient(to right, transparent, #2563eb, transparent);
+}
+```
+
+
+
+
+```css
+hr.dotted {
+ border: none;
+ border-top: 4px dotted #94a3b8;
+ width: 30%;
+ margin-inline: auto;
+}
+```
+
+
+
+
+:::tip Reset first
+Browsers add their own border style and margin to `
`. Setting `border: none` first, then adding the style you want, gives you a predictable result in every browser.
+:::
+
+## Accessibility and Global Readers
+
+Not everyone sees the page in the same way, so it helps to know what happens behind the scenes.
+
+- **Screen readers** usually announce `
` as a **separator**. Some readers skip it, and others say the word. This is why you should use it only when the break is meaningful.
+- **Decorative lines** made with CSS borders are ignored by assistive tools. That is good when the line is only for looks.
+- **Contrast matters.** A very light gray line on a white background may be invisible for low-vision users. Choose a color that can be seen.
+- **Right-to-left languages** such as Arabic and Hebrew work fine with `
`, because it spans the full width of its container.
+- **Do not rely on the line alone.** If a new section is important, add a heading, which also helps translation tools and search engines.
+
+## Choosing the Right Tool
+
+`
` is not the only way to separate content. Pick the tool that matches your goal.
+
+| Goal | Best choice |
+| :-- | :-- |
+| Change of topic inside a section | `
` |
+| A new major section of the page | A heading, like `` |
+| A purely visual line, such as under a title | CSS `border-bottom` |
+| Space between two blocks | CSS `margin` or `padding` |
+| Separate items in a list | Use list styling or `border` on each item |
+
+## Common Mistakes
+
+### Mistake 1: Using `
` everywhere
+
+```html
+
+
` just because it looks the right size?
-3. What does it mean to "skip a heading level," and why should you avoid it?
-4. How does a screen reader user benefit from real headings?
-5. Where should a subtitle like "The complete beginner's guide" go?
-
-
-
\ No newline at end of file
+Next, learn how to write body text in [Paragraphs](./paragraphs).
\ No newline at end of file
diff --git a/tutorials/html/03-text-content/horizontal-rule.mdx b/tutorials/html/03-text-content/horizontal-rule.mdx
index 8c9aa1236..f41fbd466 100644
--- a/tutorials/html/03-text-content/horizontal-rule.mdx
+++ b/tutorials/html/03-text-content/horizontal-rule.mdx
@@ -1,15 +1,339 @@
---
-id: horizontal-rule
-title: "Horizontal Rules: The hr Tag for Thematic Breaks"
+id: html-horizontal-rule
+title: "HTML Horizontal Rule"
sidebar_label: "Horizontal Rule"
sidebar_position: 5
slug: /html/text-content/horizontal-rule
-description: "Explore the hr element in HTML to create thematic breaks, section dividers, and visual content shifts across web pages."
+description: "Learn how to use the HTML hr tag to mark a thematic break between topics. Understand its meaning, default look, how to style it with CSS, accessibility tips, and common mistakes, explained clearly on CodeHarborHub."
keywords:
+ - HTML horizontal rule
- HTML hr tag
- - horizontal rule
- - thematic break HTML
- - section divider HTML
+ - HTML thematic break
+ - style hr with CSS
+ - HTML divider line
+ - HTML hr accessibility
+ - HTML void elements
+ - HTML separator
+ - learn HTML hr
- CodeHarborHub HTML
-tags: [html, hr-tag, layout, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, horizontal-rule, text, frontend]
+---
+
+Think about reading a story. Suddenly the writer leaves a small gap, maybe adds a line or a few stars, and starts again in a new place or at a new time. You feel the change right away. Nobody had to explain it.
+
+HTML has a tool for exactly this moment: the **horizontal rule**, written as `
`. It draws a line across the page, but its real job is not decoration. It tells the reader, "The topic is changing here."
+
+
+
+
+## What You Will Learn
+
+- What the `
` tag is and what it means
+- When a horizontal rule is the right choice
+- How to style it with CSS, since old HTML attributes are outdated
+- How screen readers treat it
+- Common mistakes, and better alternatives
+
+## The Basics
+
+The `
` tag creates a **thematic break** between two blocks of content. It is a **void element**, which means it has no content inside and no closing tag. (You met void elements in the [Line Breaks](./line-breaks) lesson.)
+
+
+
+
+```html title="index.html"
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+```
+
+
+
+
+
+<>
+Morning Routine
+I start my day with a glass of water and a short walk.
+
+
+
+Evening Routine
+I finish my day by reading for twenty minutes.
+>
+
+
+
+
+
+The browser draws a thin line across the full width of its container, with a little space above and below. It is a block-level element, so it always sits on its own row.
+
+:::info Two ways to write it
+In plain HTML, both `
` and `
` work. In MDX and JSX, use `
`, because unclosed tags cause errors there.
+:::
+
+## What Does "Thematic Break" Mean?
+
+In older HTML, `
` meant "horizontal **rule**", so people thought of it only as a line. In modern HTML, the meaning is a **shift in theme** at the paragraph level.
+
+Here is the difference in simple terms.
+
+| Old idea | Modern idea |
+| :-- | :-- |
+| "Draw a line here." | "The subject changes here." |
+| About appearance | About meaning |
+| Visual decoration | Content structure |
+
+That is why the line you see is only the **default look**. The meaning stays even if you restyle it.
+
+## When to Use `
`
+
+Use it when there is a real change of topic inside a section, but the change is too small for a new heading.
+
+- **A scene change** in a story
+- **A shift in subject** between two paragraphs
+- **A separator** between a main article and its notes or sign-off
+- **A pause** between a question and its long answer
+
+
+
+
+```html title="story.html"
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+```
+
+
+
+
+
+<>
+Amara closed her laptop and looked out of the window. The rain had stopped.
+
+
+
+Three weeks later, her first app was live in more than thirty countries.
+>
+
+
+
+
+
+A quick test: **if you removed the line, would the change of topic still be clear?** If yes, you probably do not need `
`. If a reader might get confused, it helps.
+
+## Old Attributes Are Gone: Use CSS
+
+Old tutorials show attributes like `width`, `size`, `align`, and `noshade` on `
`. These are **deprecated**. They still work in some browsers, but you should not use them. CSS gives you full control instead.
+
+| Old attribute | Modern CSS |
+| :-- | :-- |
+| `width="50%"` | `width: 50%;` |
+| `size="5"` | `border-width` or `height` |
+| `align="center"` | `margin-inline: auto;` |
+| `noshade` | `border-style` and `background` |
+
+### A Clean Custom Line
+
+
+
+
+```html title="styled-hr.html"
+
+
+First topic.
+
+Second topic.
+```
+
+
+
+
+
+<>
+First topic.
+
+Second topic.
+>
+
+
+
+
+
+### A Few More Styles
+
+
+
+
+```css
+hr.dashed {
+ border: none;
+ border-top: 2px dashed #64748b;
+}
+```
+
+
+
+
+```css
+hr.fade {
+ height: 2px;
+ border: none;
+ background: linear-gradient(to right, transparent, #2563eb, transparent);
+}
+```
+
+
+
+
+```css
+hr.dotted {
+ border: none;
+ border-top: 4px dotted #94a3b8;
+ width: 30%;
+ margin-inline: auto;
+}
+```
+
+
+
+
+:::tip Reset first
+Browsers add their own border style and margin to `
`. Setting `border: none` first, then adding the style you want, gives you a predictable result in every browser.
+:::
+
+## Accessibility and Global Readers
+
+Not everyone sees the page in the same way, so it helps to know what happens behind the scenes.
+
+- **Screen readers** usually announce `
` as a **separator**. Some readers skip it, and others say the word. This is why you should use it only when the break is meaningful.
+- **Decorative lines** made with CSS borders are ignored by assistive tools. That is good when the line is only for looks.
+- **Contrast matters.** A very light gray line on a white background may be invisible for low-vision users. Choose a color that can be seen.
+- **Right-to-left languages** such as Arabic and Hebrew work fine with `
`, because it spans the full width of its container.
+- **Do not rely on the line alone.** If a new section is important, add a heading, which also helps translation tools and search engines.
+
+## Choosing the Right Tool
+
+`
` is not the only way to separate content. Pick the tool that matches your goal.
+
+| Goal | Best choice |
+| :-- | :-- |
+| Change of topic inside a section | `
` |
+| A new major section of the page | A heading, like `` |
+| A purely visual line, such as under a title | CSS `border-bottom` |
+| Space between two blocks | CSS `margin` or `padding` |
+| Separate items in a list | Use list styling or `border` on each item |
+
+## Common Mistakes
+
+### Mistake 1: Using `
` everywhere
+
+```html
+
+
Morning Routine
+I start my day with a glass of water and a short walk.
+ ++ +
Evening Routine
+I finish my day by reading for twenty minutes.
+``` + +Morning Routine
+I start my day with a glass of water and a short walk.
+ ++ +
Evening Routine
+I finish my day by reading for twenty minutes.
+> +Amara closed her laptop and looked out of the window. The rain had stopped.
+ ++ +
Three weeks later, her first app was live in more than thirty countries.
+``` + +Amara closed her laptop and looked out of the window. The rain had stopped.
+ ++ +
Three weeks later, her first app was live in more than thirty countries.
+> +First topic.
++
Second topic.
+``` + +First topic.
++
Second topic.
+> +` everywhere + +```html + +
Paragraph one.
++
Paragraph two.
++
Paragraph three.
++``` + +When every paragraph gets a line, the break loses its meaning. Save it for real changes of topic. + +### Mistake 2: Using it only for decoration + +If you only want a line under a title, a CSS `border-bottom` is the better tool. It does not say "the topic changed" when nothing changed. + +### Mistake 3: Using deprecated attributes + +```html + +
+ + +
+``` + +### Mistake 4: Writing a closing tag + +`` is not valid. Void elements never have a closing tag. + +### Mistake 5: Using it instead of headings + +A line does not tell users what the next section is about. If the next part has its own subject, give it a [heading](./headings). + +## Try It Yourself + +Here is a small exercise. + +1. Create a file called `travel-diary.html`. +2. Write two short paragraphs about a place you visited or want to visit. +3. Add a third paragraph about a **different day** or a **different place**. +4. Place an `
` between the parts where the story changes. +5. Add a CSS class that makes your line 40% wide, centered, and dotted. +6. Remove the `
` and read the text again. Is the change still clear? + +
+ +## Quick Recap + +Click a question to check your answer. + +
1. What does `
` represent in modern HTML?
+
+A thematic break, meaning a shift in topic between blocks of content.
+
+2. Does `
` need a closing tag?
+
+No. It is a void element and has no content to wrap.
+
+3. How should you change the width or color of a horizontal rule today?
+ +Use CSS, such as `width`, `border-top`, and `margin`. The old HTML attributes are deprecated. + +4. When is a heading better than `
`?
+
+When the next part is a new section with its own subject. A heading names that section, and a line does not.
+
+5. Why should you not use `
` between every paragraph?
+
+Too many breaks make each one meaningless, and screen readers may announce a separator every time.
+
+` marks a **change of theme**, not just a line on the screen. +- It is a **void, block-level** element with no closing tag. +- Style it with **CSS**. The old attributes are deprecated. +- Use it sparingly, and prefer headings for new sections and CSS borders for decoration. +- Choose visible colors and think about screen readers so every learner can follow your page. + +Next, learn how to show importance and attention in your text with [Strong and Bold](./strong-and-bold). \ No newline at end of file diff --git a/tutorials/html/03-text-content/line-breaks.mdx b/tutorials/html/03-text-content/line-breaks.mdx index 57c239bf5..c5ddb3059 100644 --- a/tutorials/html/03-text-content/line-breaks.mdx +++ b/tutorials/html/03-text-content/line-breaks.mdx @@ -1,15 +1,367 @@ --- -id: line-breaks -title: "Line Breaks and Forced Spaces in HTML" +id: html-line-breaks +title: "HTML Line Breaks" sidebar_label: "Line Breaks" sidebar_position: 4 slug: /html/text-content/line-breaks -description: "Learn when and how to use the self-closing br tag for forcing line breaks in addresses, poetry, and inline text blocks without breaking paragraphs." +description: "Understand how the HTML br tag works, when to use a line break instead of a new paragraph, how to handle addresses and poems, and which CSS options and mistakes to know. A clear, step-by-step guide on CodeHarborHub." keywords: + - HTML line break - HTML br tag - - line break tag - - forced line breaks - - inline breaks HTML + - HTML br vs p + - HTML new line + - HTML wbr tag + - HTML white-space pre-line + - HTML void elements + - HTML address formatting + - learn HTML line breaks - CodeHarborHub HTML -tags: [html, line-breaks, formatting, beginner] ---- \ No newline at end of file +tags: [html, web-development, beginner, line-break, text, frontend] +--- + +In the last lesson you learned that pressing Enter in your code does **not** start a new line on the page. The browser ignores it. So what do you do when you really do want a new line, such as in an address or a poem, without starting a whole new paragraph? + +That is the job of the `
` tag. It is tiny, but understanding **when** to use it (and when not to) is what separates clean HTML from messy HTML. This lesson explains both. + +
+ +## What You Will Learn + +- What the `
` tag does, in plain terms +- What a **void element** is and why `
` has no closing tag +- The difference between a line break and a new paragraph +- Where line breaks make sense, and where they do not +- Better alternatives using CSS +- How to control where a long word may break with `
+ Roses are red + Violets are blue + I love HTML +
+``` + ++ Roses are red + Violets are blue + I love HTML +
+> +` Tag + +`br` stands for **break**. Place it exactly where you want the line to end. + +
+ Roses are red
+ Violets are blue
+ I love HTML
+
+ Roses are red
+ Violets are blue
+ I love HTML
+
` + +Here is a simple way to picture it. + +- **Typing text** is like writing on a typewriter. The words keep flowing to the right until the paper edge, then wrap. +- **`
`** is like pressing the carriage return on that typewriter. The next word starts at the beginning of a new line, even though you were not at the edge yet. + +That is all it does. It does not create a new block, and it does not add extra space. It only says, "continue from the next line." + +## Void Elements: Why No Closing Tag? + +Most HTML elements wrap around content, like `
text
`. The `` tag has **nothing to wrap**, because a line break has no content inside it. Elements like this are called **void elements**. + +| Wrapping element | Void element | +| :-- | :-- | +| `
Hello
` | `` | +| `Hi` | `
` | +| `Link` | `
` |
+
+You may see three ways of writing it, and all of them work in HTML.
+
+```html
++
+
+``` + +:::info Which one should I use? +In plain HTML, `
` is perfectly valid. The self-closing form `
` is required in JSX and MDX, and it is common in many style guides. Since our CodeHarborHub docs run on MDX, `
` is the safest habit. +::: + +## Line Break vs New Paragraph + +This is the most important idea in the lesson. Both give you a new line, but they mean different things. + +| | `
` | `
` |
+| :-- | :-- | :-- |
+| Meaning | "Same thought, next line" | "A new idea starts here" |
+| Extra space between lines | No | Yes (default margin) |
+| Structure | Stays inside one element | Creates a separate block |
+| Best for | Addresses, poems, sign-offs | Normal body text |
+
+A quick test: **if you could put a full stop and start a new idea, use a new paragraph. If the lines belong together as one unit, use a line break.**
+
+### Side by Side
+
+ I woke up early today. Then I went for a long walk.
+ Priya Sharma I woke up early today. Then I went for a long walk.
+ Priya Sharma
+ 221B Green Street
+ Indore, Madhya Pradesh
+
+ 221B Green Street
+ Indore, Madhya Pradesh
+
` when the **line ending itself is part of the content**.
+
+- **Postal addresses:** name, street, and city on separate lines
+- **Poems and verses:** each line has to stay where the poet put it
+- **Sign-offs:** "Thanks," then your name on the next line
+- **Short labeled lines:** for example, contact details in a footer
+
+```html title="signoff.html"
+
+ Thanks for reading,
+ Team CodeHarborHub
+
` to create space + +```html + +
First idea.
++
Second idea.
+``` + +Stacking breaks is a layout trick, not meaning. It behaves differently on different screen sizes, and screen readers may announce the empty lines. Use CSS `margin` instead. + +```html + +First idea.
+Second idea.
+``` + +### Do not use `` to split every sentence into a paragraph + +If your lines are separate ideas, write separate `
` elements. It makes the structure clear to search engines and assistive tools.
+
+### Do not use `
+Line one of my note
+Line two of my note
+Line three of my note
+
+Line one of my note
+Line two of my note
+Line three of my note
+
` inside lists or tables to fake layout
+
+There are proper elements for lists and tables. Reaching for `
` there is usually a sign that another tag fits better.
+
+:::warning Accessibility note
+Screen readers treat line breaks inside text as part of the reading flow. Real structure, like separate paragraphs or list items, gives users clearer signals than many `
` tags in a row.
+:::
+
+## Better Options with CSS
+
+Sometimes you have text that already contains line endings, like content from a database or a text box. Instead of adding `
` by hand, CSS can honor the line breaks for you.
+
+
` |
+| Many stored line endings in existing text | CSS `white-space: pre-line` |
+| Exact spaces and line breaks, like code | The `
` element | +| Extra space between blocks | CSS `margin` or `padding` | +| A new idea | A new `` | + +## Bonus: The `
` Tag + +`
` **forces** a break. Its quieter cousin, `` (word break opportunity), only **suggests** one. The browser breaks the line there **only if it needs to**. + +That helps with very long words or URLs that could overflow a small screen. + +```html + + Read our guide at + https://codeharborhub.
+``` + +On a wide screen, the text looks normal. On a narrow phone, the browser can wrap at any `github. io/tutorial /html /text-content + ` instead of overflowing. + +## Common Mistakes + +| Mistake | Why it is a problem | Fix | +| :-- | :-- | :-- | +| Writing `` | It is not valid HTML | Use `
` | +| Many `
` in a row for spacing | Layout trick, poor accessibility | Use CSS `margin` | +| A `
` right after every sentence | Turns body text into a choppy list | Use real paragraphs | +| Using `
` outside any text container | Can produce unpredictable spacing | Put it inside `` or another text element | + +## Try It Yourself + +Practice with this small project. + +1. Create `contact-card.html`. +2. Add an `
` that says **Contact Us**. +3. Inside one `
`, write your name, city, and email on **three lines** using `
`. +4. Add a **second** `` with a normal sentence, like "We reply within a day." +5. Compare the spacing between the two blocks. Can you explain why the gaps look different? + +If you can explain it, you truly understand line breaks. + +
+
+ +## Quick Recap + +Click a question to check your answer. + +++ +1. What does `
+ +It ends the current line and starts the text on a new line, without starting a new paragraph. + +
` do?++ +2. Why does `
+ +It is a void element. A line break has no content to wrap, so there is nothing to close. + +
` have no closing tag?++ +3. When should you choose `
+ +When you are starting a new idea. Use `` over `
`?
` only when the lines belong together as one unit, like an address. + +++ +4. Why is stacking several `
+ +It mixes layout with content, behaves inconsistently on different screens, and is not friendly to screen readers. CSS margin is better. + +
` tags a poor way to add space?++ +## Key Takeaways + +- Pressing Enter in your code does not create a new line on the page. Use `5. What is the difference between `
+ +`
` and ``?
` always forces a break. `` only allows a break if the text needs one, such as in a long word on a small screen. + +
` for that. +- `
` is a **void element**. It has no content and no closing tag. +- Use `
` when the line ending is part of the content, such as addresses, poems, and sign-offs. +- Use `` for new ideas, and CSS for spacing. +- `white-space: pre-line` keeps existing line breaks, and `
` suggests optional break points. + +Next, learn how to separate topics with a visual divider in [Horizontal Rule](./horizontal-rule). \ No newline at end of file diff --git a/tutorials/html/03-text-content/paragraphs.mdx b/tutorials/html/03-text-content/paragraphs.mdx index 426b34192..dd10eb906 100644 --- a/tutorials/html/03-text-content/paragraphs.mdx +++ b/tutorials/html/03-text-content/paragraphs.mdx @@ -1,15 +1,332 @@ --- -id: paragraphs -title: "HTML Paragraphs: Structuring Blocks of Text" +id: html-paragraphs +title: "HTML Paragraphs" sidebar_label: "Paragraphs" sidebar_position: 3 slug: /html/text-content/paragraphs -description: "Understand the paragraph tag, block-level text rendering, browser default margins, and proper text grouping techniques in HTML." +description: "Learn how to write paragraphs in HTML with the p tag. Understand how browsers handle spaces and line breaks, how to style paragraphs with CSS, and how to avoid common beginner mistakes, explained in simple language on CodeHarborHub." keywords: + - HTML paragraphs + - HTML p tag - HTML paragraph tag - - p tag HTML - - block level text - - text blocks HTML + - HTML whitespace collapsing + - HTML block level elements + - style HTML paragraphs with CSS + - HTML paragraph best practices + - learn HTML paragraphs - CodeHarborHub HTML -tags: [html, paragraph, markup, beginner] ---- \ No newline at end of file +tags: [html, web-development, beginner, paragraphs, text, frontend] +--- + +Imagine opening a book where every page is one giant wall of words. No gaps, no breaks, nothing to rest your eyes on. You would probably close it after a few lines, right? + +That is exactly why **paragraphs** exist. They chop your writing into small, friendly chunks so readers can breathe, follow your ideas, and keep going. In HTML, the tool for that job is the humble ` ` tag, and it is one you will use in almost every page you ever build. + +
+
+ +## What You Will Learn + +By the end of this lesson, you will be able to: + +- Write a paragraph with the `` tag +- Understand why your extra spaces and blank lines seem to "disappear" +- Style paragraphs with CSS so they are comfortable to read +- Avoid the mistakes almost every beginner makes at least once + +:::info Good news +This is one of the easiest lessons in the whole tutorial. If you can type a sentence, you can write a paragraph. +::: + +## Your First Paragraph + +A paragraph starts with `
` and ends with `
`. Everything you put between the two tags becomes one paragraph. + ++ + +Notice two things. Each paragraph starts on its own line, and the browser adds a little space between them. You did not have to ask for that. The browser does it for you. + +## Paragraphs Are "Block" Elements + +In HTML, a paragraph is a **block-level element**. Picture it as a rectangular box that stretches across the full width of its container. Because of that: + +- A paragraph always starts on a **new line** +- It takes up the **whole row**, even if the text is short +- The browser adds a **margin** above and below it (about 16px by default) + +Think of paragraphs like boxes on a shelf. Each box gets its own row, and there is a small gap between rows. + +## Why Did My Spaces Disappear? + +Here is something that surprises almost everyone at first. Look at this code. + ++ +```html title="index.html" + +Hello! This is my very first paragraph.
+And this is my second one. See how it starts on a new line?
+``` + ++ + ++<> + + +Hello! This is my very first paragraph.
+And this is my second one. See how it starts on a new line?
+> ++ + +You typed a bunch of spaces and blank lines, but the browser shows one tidy line. That is not a bug. It is called **whitespace collapsing**. The browser squishes any run of spaces, tabs, and line breaks into a single space. + +Why does it work this way? So you can format your code however you like, with indentation and line wraps, without changing what visitors see. + +:::tip Want to keep your spacing? +If you truly need spaces and line breaks preserved, you have two options. Use `+ +```html title="spaces.html" + ++ This paragraph has + lots of extra spaces + + + and blank lines. +
+``` + ++ + ++<> + + ++ This paragraph has + lots of extra spaces + + + and blank lines. +
+> +
` for a line break (next lesson), or use the `` tag for preformatted text. +::: + +## Long Text? Break It Up + +Compare these two versions of the same text. Which one would you rather read? + ++ + +A good rule of thumb: **one paragraph, one idea**. When your idea changes, start a new paragraph. + +## Styling Paragraphs with CSS + +The default look works, but a few small CSS tweaks can make your text much nicer to read. + ++ +```html + ++ HTML is the skeleton of every web page. It tells the browser what is a title, + what is a paragraph, and what is a link. CSS then adds colors and layout, and + JavaScript brings the page to life with interaction. Learning all three takes + time, but starting with HTML gives you a strong base for everything else. +
+``` + ++ +```html + ++ HTML is the skeleton of every web page. It tells the browser what is a title, + what is a paragraph, and what is a link. +
++ CSS then adds colors and layout, and JavaScript brings the page to life with + interaction. +
++ Learning all three takes time, but starting with HTML gives you a strong base + for everything else. +
+``` + ++ + +Here is what each property does: + +| CSS property | What it does | Friendly tip | +| :-- | :-- | :-- | +| `font-size` | Changes the text size | Keep body text at 16px or larger | +| `line-height` | Sets the space between lines | Try 1.5 to 1.8 for easy reading | +| `max-width` | Limits how wide the text can get | Around `60ch` to `75ch` works well | +| `color` | Sets the text color | Make sure it contrasts with the background | +| `text-align` | Aligns the text | Left-aligned is easiest for most readers | +| `margin` | Changes the gap between paragraphs | Use `margin-bottom` for even spacing | + +## Mistakes Everyone Makes (and Easy Fixes) + +Do not worry if you have already done these. Every developer has. + +### Mistake 1: Using empty paragraphs for spacing + +```html + ++ +```html title="styled-paragraph.html" + + + ++ Comfortable text is not an accident. A little extra line height and a limited + width make long paragraphs far easier on the eyes. +
+``` + ++ + ++<> + + ++ Comfortable text is not an accident. A little extra line height and a limited + width make long paragraphs far easier on the eyes. +
+> +First idea.
+ + +Second idea.
+``` + +Empty `` tags add noise, not meaning. If you want more space, use CSS `margin` or `padding` instead. + +### Mistake 2: Putting one paragraph inside another + +```html + ++ Outer paragraph +
Inner paragraph
+ +``` + +Paragraphs cannot contain other paragraphs. The browser will quietly close the first one as soon as it sees the second, and your layout will not match what you wrote. + +### Mistake 3: Putting block elements inside a paragraph + +A `