0
0
CSSmarkup~30 mins

Text alignment in CSS - Mini Project: Build & Apply

Choose your learning style9 modes available
Text Alignment with CSS
📖 Scenario: You are creating a simple webpage for a local bakery. The bakery wants the text on their homepage to look neat and organized. They want the main heading to be centered, the introduction paragraph to be left-aligned, and the contact information to be right-aligned.
🎯 Goal: Build a webpage with three text sections: a centered heading, a left-aligned paragraph, and a right-aligned contact info line using CSS text alignment.
📋 What You'll Learn
Use semantic HTML5 elements:
,
, and
.
Center the heading text inside the
.
Left-align the paragraph text inside the
.
Right-align the contact information inside the
.
Use CSS classes to apply text alignment styles.
Ensure the page is responsive and text remains aligned on different screen sizes.
💡 Why This Matters
🌍 Real World
Text alignment is a basic but essential skill for creating readable and visually appealing webpages. Businesses often want their headings, paragraphs, and contact info aligned differently to guide visitor attention.
💼 Career
Web developers must know how to use CSS text alignment to meet design requirements and improve user experience on websites.
Progress0 / 4 steps
1
Create the HTML structure with text content
Write the HTML code to create a <header> with a <h1> containing the text "Welcome to Sweet Treats Bakery", a <main> with a <p> containing the text "Freshly baked goods every day.", and a <footer> with a <p> containing the text "Contact us: 123-456-7890".
CSS
Need a hint?

Use semantic tags and place the exact text inside the correct tags.

2
Add CSS classes for text alignment
Add a class called center-text to the <h1>, a class called left-text to the <p> inside <main>, and a class called right-text to the <p> inside <footer>.
CSS
Need a hint?

Add the class attribute exactly as shown to each text element.

3
Write CSS rules for text alignment
Write CSS rules for the classes center-text, left-text, and right-text to set their text-align properties to center, left, and right respectively.
CSS
Need a hint?

Use the CSS property text-align inside each class rule.

4
Add responsive meta tag and final HTML structure
Add the <!DOCTYPE html> declaration at the top, wrap the content inside <html lang="en"> and <body> tags, and add the responsive meta tag <meta name="viewport" content="width=device-width, initial-scale=1.0"> inside the <head> section.
CSS
Need a hint?

Make sure to add the doctype, html, head, and body tags properly with the viewport meta tag for responsiveness.