📖 Scenario: You are creating a simple webpage to introduce yourself. You want to add extra information to your HTML tags to make your page more meaningful and accessible.
🎯 Goal: Build a basic HTML page that uses attributes to add details to elements like links and images.
📋 What You'll Learn
Create an HTML skeleton with html, head, and body tags
Add a title inside the head
Add an img tag with src and alt attributes
Add an a (link) tag with href and target attributes
Use attributes correctly inside the opening tags
💡 Why This Matters
🌍 Real World
Webpages use attributes to provide important details about elements, like where images come from or where links go.
💼 Career
Understanding attributes is essential for creating accessible, well-structured websites and for working with web developers and designers.
Progress0 / 4 steps
1
Create the basic HTML structure
Write the basic HTML skeleton with html, head, and body tags. Inside head, add a title tag with the text My First Page.
HTML
Hint
Remember the basic HTML page starts with <!DOCTYPE html> and has <html>, <head>, and <body> tags.
2
Add an image with attributes
Inside the body, add an img tag with the src attribute set to "profile.jpg" and the alt attribute set to "My profile picture".
HTML
Hint
The img tag needs src to show the image and alt to describe it for screen readers.
3
Add a link with attributes
Below the image, add an a tag with the href attribute set to "https://example.com" and the target attribute set to "_blank". The link text should be Visit Example.
HTML
Hint
The a tag creates a link. Use href for the URL and target="_blank" to open it in a new tab.
4
Add a heading with a class attribute
Above the image, add an h1 heading with the text Welcome to My Page and add a class attribute with the value main-title.
HTML
Hint
The class attribute helps identify elements for styling or scripting. Add it inside the opening h1 tag.
Practice
(1/5)
1. What is the main purpose of attributes in HTML elements?
easy
A. To add extra information or settings to elements
B. To create new HTML elements
C. To write comments inside HTML
D. To link CSS files to the HTML
Solution
Step 1: Understand what attributes do
Attributes provide extra details or settings inside an element's opening tag.
Step 2: Compare options with attribute purpose
Only To add extra information or settings to elements correctly describes adding extra information or settings to elements.
Final Answer:
To add extra information or settings to elements -> Option A
Quick Check:
Attributes add details = B [OK]
Hint: Attributes add info inside tags, not create elements [OK]
Common Mistakes:
Confusing attributes with creating elements
Thinking attributes are for comments
Mixing attributes with linking CSS
2. Which of the following is the correct way to add an attribute to an HTML element?
easy
A.
Content
B.
Content
C.
Content
D.
Solution
Step 1: Check attribute syntax rules
Attributes go inside the opening tag with name="value" or name='value'.