0
0
HTMLmarkup~20 mins

Preformatted text in HTML - Mini Project: Build & Apply

Choose your learning style9 modes available
Using Preformatted Text in HTML
šŸ“– Scenario: You are creating a simple webpage to show a poem exactly as it is typed, preserving spaces and line breaks.
šŸŽÆ Goal: Build an HTML page that uses the <pre> tag to display text with all spaces and line breaks preserved.
šŸ“‹ What You'll Learn
Create a basic HTML5 page structure
Add a <pre> element containing the exact poem text
Ensure the page uses semantic HTML with <main> and <header>
Include a page title in the <title> tag
Use UTF-8 charset and responsive viewport meta tags
šŸ’” Why This Matters
šŸŒ Real World
Showing code snippets, poems, or any text where exact spacing and line breaks matter is common in blogs, documentation, and educational sites.
šŸ’¼ Career
Understanding how to preserve text formatting with <pre> is important for web developers creating readable code examples or formatted text content.
Progress0 / 4 steps
1
Create the basic HTML5 page structure
Write the basic HTML5 skeleton with lang="en", <head> containing <meta charset="UTF-8">, <meta name="viewport" content="width=device-width, initial-scale=1.0">, and a <title> with the text Preformatted Text Example. Also add an empty <body> tag.
HTML
Need a hint?

Start by typing the standard HTML5 page structure with the required meta tags and title.

2
Add semantic structure with header and main
Inside the <body>, add a <header> containing an <h1> with the text Poem Display. Below the header, add a <main> element. Leave the <main> empty for now.
HTML
Need a hint?

Use semantic tags to organize your page content clearly.

3
Add the poem text inside a preformatted block
Inside the <main> element, add a <pre> tag containing the exact text below, preserving spaces and line breaks:

Roses are red, Violets are blue, Sugar is sweet, And so are you.
HTML
Need a hint?

The <pre> tag keeps all spaces and line breaks exactly as typed.

4
Add a footer with a copyright notice
Below the <main> element, add a <footer> containing a <p> with the text Ā© 2024 Poetry Inc.
HTML
Need a hint?

Use the <footer> tag for page footers and add a paragraph inside it.