0
0
HTMLmarkup~20 mins

What are attributes in HTML - Practice Questions & Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Attribute Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding HTML Attributes
Which of the following best describes what an attribute in an HTML tag does?
AIt provides extra information about an element, like its ID or style.
BIt creates a new HTML element inside the tag.
CIt removes the element from the page.
DIt changes the browser's default font.
Attempts:
2 left
💡 Hint
Think about how you add details to an HTML tag to change its behavior or appearance.
📝 Syntax
intermediate
1:30remaining
Correct Attribute Syntax
Which option shows the correct way to add a class attribute to a <div> element?
HTML
<div ???>Content</div>
Aclass=container
Bclass='container'
Cclass:"container"
Dclass-container
Attempts:
2 left
💡 Hint
Attributes need an equals sign and quotes around the value.
rendering
advanced
2:00remaining
Effect of the alt Attribute on Images
What will the browser display if an image has a broken link but includes an alt attribute like alt="Logo"?
HTML
<img src="broken-link.jpg" alt="Logo">
AThe browser will crash.
BNothing will show; the image area will be blank.
CThe broken image icon with no text.
DThe text 'Logo' will be shown in place of the image.
Attempts:
2 left
💡 Hint
Alt text helps when images cannot load.
selector
advanced
2:00remaining
Selecting Elements by Attribute in CSS
Which CSS selector will style all <a> elements that have a title attribute?
Aa[title] { color: blue; }
Ba.title { color: blue; }
Ca#title { color: blue; }
Da(title) { color: blue; }
Attempts:
2 left
💡 Hint
Attribute selectors use square brackets.
accessibility
expert
2:30remaining
Role of ARIA Attributes
What is the main purpose of ARIA attributes like aria-label in HTML?
ATo add animations to elements.
BTo change the visual style of elements.
CTo improve accessibility by providing extra information to screen readers.
DTo make elements draggable.
Attempts:
2 left
💡 Hint
ARIA helps people who use assistive technology.