Bird
Raised Fist0
HTMLmarkup~20 mins

Line breaks and horizontal rules in HTML - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Line Breaks and Rules Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate
2:00remaining
What is the visual output of this HTML snippet?
Look at this HTML code and choose what you will see in the browser.
HTML
<p>Hello<br>World</p>
AHello and World appear on the same line with a space between.
BOnly Hello appears; World is hidden.
CHelloWorld appears as one word with no space.
DHello and World appear on two separate lines.
Attempts:
2 left
💡 Hint
The
tag creates a line break inside text.
📝 Syntax
intermediate
2:00remaining
Which option correctly adds a horizontal rule in HTML?
Choose the correct HTML tag that creates a horizontal line across the page.
A<line>
B<break>
C<hr>
D<hline>
Attempts:
2 left
💡 Hint
The horizontal rule tag is a self-closing tag with two letters.
🧠 Conceptual
advanced
2:00remaining
What is the difference between
and
in HTML?
Choose the option that best explains the difference between these two tags.
A<br> inserts a line break inside text; <hr> inserts a horizontal line separating content sections.
B<br> creates a horizontal line; <hr> creates a line break inside text.
C<br> and <hr> both create horizontal lines but with different thickness.
D<br> is used for paragraphs; <hr> is used for line breaks.
Attempts:
2 left
💡 Hint
Think about how text flows and how sections are separated visually.
❓ accessibility
advanced
2:00remaining
How should you improve accessibility when using
tags?
Which option is the best practice to make horizontal rules accessible to screen readers?
AUse <hr> without any attributes; screen readers ignore it automatically.
BAdd an aria-label or role="separator" to describe the purpose of the <hr>.
CReplace <hr> with multiple <br> tags for better accessibility.
DAdd a title attribute with decorative text to the <hr>.
Attempts:
2 left
💡 Hint
Think about how screen readers understand page structure.
❓ selector
expert
2:00remaining
Which CSS selector targets only
elements inside paragraphs?
Choose the CSS selector that applies styles only to
tags that are inside

tags.

Ap br
Bbr p
Cp > br
Dp + br
Attempts:
2 left
💡 Hint
Think about descendant selectors versus child selectors.

Practice

(1/5)
1. What does the <br> tag do in HTML?
easy
A. It makes text bold.
B. It adds a line break inside text.
C. It creates a horizontal line across the page.
D. It inserts an image.

Solution

  1. Step 1: Understand the purpose of <br>

    The <br> tag is used to break a line and continue text on the next line.
  2. Step 2: Compare with other tags

    The <hr> tag creates a horizontal line, not a line break. Bold text uses <strong> or <b> tags. Images use <img> tag.
  3. Final Answer:

    It adds a line break inside text. -> Option B
  4. Quick Check:

    <br> = line break [OK]
Hint: Remember: <br> breaks line, <hr> draws line [OK]
Common Mistakes:
  • Confusing <br> with <hr>
  • Thinking <br> makes text bold
  • Using <br> to insert images
2. Which of the following is the correct syntax to add a horizontal rule in HTML?
easy
A.
B. <hl>
C. <line>
D.

Solution

  1. Step 1: Identify the tag for horizontal rule

    The correct tag to add a horizontal line is <hr>.
  2. Step 2: Check other options

    <br> adds a line break, <line> and <hl> are not valid HTML tags.
  3. Final Answer:

    <hr> -> Option D
  4. Quick Check:

    <hr> = horizontal rule [OK]
Hint: Use <hr> for horizontal lines, not <br> [OK]
Common Mistakes:
  • Using <br> instead of <hr>
  • Typing invalid tags like <line> or <hl>
  • Forgetting <hr> is self-closing
3. What will the following HTML code display?
<p>Hello<br>World<hr><p>Goodbye</p>
medium
A. Hello and World on the same line, then a horizontal line, then Goodbye below.
B. Hello and World on the same line, no horizontal line, then Goodbye below.
C. Hello and World on separate lines, then a horizontal line, then Goodbye below.
D. Hello and World on separate lines, no horizontal line, then Goodbye below.

Solution

  1. Step 1: Analyze <br> effect

    The <br> tag breaks the line between "Hello" and "World", so they appear on separate lines.
  2. Step 2: Analyze <hr> effect

    The <hr> tag adds a horizontal line below "World" before the next paragraph "Goodbye".
  3. Final Answer:

    Hello and World on separate lines, then a horizontal line, then Goodbye below. -> Option C
  4. Quick Check:

    <br> = line break, <hr> = horizontal line [OK]
Hint: <br> breaks line, <hr> draws line below [OK]
Common Mistakes:
  • Thinking <br> keeps text on same line
  • Ignoring the horizontal line from <hr>
  • Confusing paragraph tags with line breaks
4. Find the error in this HTML snippet:
<p>Line one<br><hr>Line two</p>
medium
A. Using <hr> inside a <p> tag is invalid HTML.
B. <br> tag is missing a closing tag.
C. <hr> should be written as <hr/> to work.
D. <p> tag should be closed before <br>.

Solution

  1. Step 1: Check tag nesting rules

    The <hr> tag is a block-level element and should not be inside a <p> tag, which is for text paragraphs.
  2. Step 2: Validate other tags

    <br> is self-closing and does not need a closing tag. <hr> can be written as <hr> or <hr/> in HTML5. <p> can contain <br> but not <hr>.
  3. Final Answer:

    Using <hr> inside a <p> tag is invalid HTML. -> Option A
  4. Quick Check:

    <hr> not allowed inside <p> [OK]
Hint: Block tags like <hr> can't go inside <p> [OK]
Common Mistakes:
  • Thinking <br> needs closing tag
  • Believing <hr> must be self-closed
  • Ignoring tag nesting rules
5. You want to separate two paragraphs with a visible line and also add a blank line between them. Which HTML code achieves this correctly?
hard
A.

First paragraph.



Second paragraph.

B.

First paragraph.


Second paragraph.

C.

First paragraph.




Second paragraph.

D.

First paragraph.

<br>


Second paragraph.

Solution

  1. Step 1: Understand spacing and line rules

    To add a blank line, use a <br> inside a paragraph or a separate paragraph with <br>.
  2. Step 2: Place horizontal rule correctly

    The <hr> tag should be outside paragraphs to separate them visually.
  3. Step 3: Evaluate options

    First paragraph.




    Second paragraph.

    uses <br> outside paragraphs which is invalid.

    First paragraph.


    Second paragraph.

    misses blank line.

    First paragraph.

    <br>


    Second paragraph.

    uses literal <br> text, not tag.

    First paragraph.



    Second paragraph.

    correctly uses a paragraph with <br> for spacing and <hr> between paragraphs.
  4. Final Answer:

    <p>First paragraph.</p><p><br></p><hr><p>Second paragraph.</p> -> Option A
  5. Quick Check:

    Use <p><br></p> for blank line, <hr> outside paragraphs [OK]
Hint: Use <p><br></p> for space, <hr> between paragraphs [OK]
Common Mistakes:
  • Placing <br> outside paragraphs
  • Using literal <br> text instead of tag
  • Putting <hr> inside paragraphs
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard