Global attributes are special attributes that can be used on any HTML element to add extra information or control behavior.
Click to reveal answer
beginner
Name three common global attributes in HTML.
Three common global attributes are: 1. id - unique identifier 2. class - groups elements 3. style - inline CSS styling
Click to reveal answer
intermediate
What does the tabindex global attribute do?
The tabindex attribute controls the order in which elements receive keyboard focus when pressing the Tab key. It helps with keyboard navigation.
Click to reveal answer
intermediate
How does the aria-label attribute help users?
The aria-label attribute provides a text label for elements, especially for screen readers. It improves accessibility by describing elements that might not have visible text.
Click to reveal answer
beginner
Can the style attribute be used on any HTML element? Why?
Yes, the style attribute is a global attribute and can be used on any HTML element to apply CSS styles directly to that element.
Click to reveal answer
Which of the following is NOT a global attribute in HTML?
Aid
Bhref
Cclass
Dstyle
✗ Incorrect
href is an attribute specific to <a> and some other elements, not a global attribute.
What does the hidden global attribute do?
AMakes the element invisible and not focusable
BChanges the text color
CAdds a tooltip
DMakes the element editable
✗ Incorrect
The hidden attribute hides the element from view and removes it from keyboard navigation.
Which global attribute helps improve accessibility by labeling elements for screen readers?
Aclass
Bstyle
Caria-label
Did
✗ Incorrect
aria-label provides descriptive text for screen readers.
How can you group multiple elements for styling or scripting?
AUsing the <code>class</code> attribute
BUsing the <code>id</code> attribute
CUsing the <code>style</code> attribute
DUsing the <code>tabindex</code> attribute
✗ Incorrect
class groups elements so CSS or JavaScript can target them together.
Which global attribute controls keyboard focus order?
Ahidden
Bstyle
Caria-label
Dtabindex
✗ Incorrect
tabindex sets the order elements receive focus when tabbing.
Explain what global attributes are and why they are useful in HTML.
Think about attributes that work everywhere in HTML.
You got /3 concepts.
Describe how the aria-label and tabindex attributes improve accessibility.
Focus on how these help people who use keyboards or screen readers.
You got /3 concepts.
Practice
(1/5)
1. Which of the following is a global attribute that can be used on any HTML element to give it a unique identifier?
easy
A. alt
B. src
C. id
D. href
Solution
Step 1: Understand what a global attribute is
Global attributes can be used on any HTML element regardless of its type.
Step 2: Identify the attribute that uniquely identifies elements
The id attribute assigns a unique identifier to an element, usable on all elements.
Final Answer:
id -> Option C
Quick Check:
Unique element identifier = id [OK]
Hint: Use id for unique element IDs on any tag [OK]
Common Mistakes:
Confusing src as global (it's for images, scripts)
Thinking href works on all elements (only links)
Using alt outside images
2. Which is the correct way to add a tooltip text to an HTML element using a global attribute?
easy
A. tooltip="Info"
B. title="Info"
C. alt="Info"
D. data-tooltip="Info"
Solution
Step 1: Identify the attribute that shows tooltip text
The title attribute is a global attribute that shows a tooltip on hover.
Step 2: Check the syntax correctness
title="Info" is the correct syntax to add tooltip text.
Final Answer:
title="Info" -> Option B
Quick Check:
Tooltip attribute = title [OK]
Hint: Use title for tooltips on any element [OK]
Common Mistakes:
Using non-existent tooltip attribute
Confusing alt (only for images)
Using custom data attributes for tooltips without scripts
3. What will be the visible effect of this HTML snippet in a browser?
A. The button element cannot have global attributes
B. The id attribute value is invalid
C. The class attribute cannot be used with hidden
D. The hidden attribute should not have a value
Solution
Step 1: Review the hidden attribute usage
The hidden attribute is a boolean attribute and should not have a value like "false"; presence means true.
Step 2: Check other attributes for correctness
id and class are valid global attributes on button. The error is only with hidden="false".
Final Answer:
The hidden attribute should not have a value -> Option D
Quick Check:
Boolean attributes have no value = hidden no value [OK]
Hint: Boolean global attributes never have values, just presence [OK]
Common Mistakes:
Giving boolean attributes values like "true" or "false"
Thinking hidden="false" means visible
Believing class and hidden conflict
5. You want to store extra information about a product in an HTML element without affecting its display or behavior. Which global attribute should you use?
hard
A. data-product-info
B. title
C. hidden
D. class
Solution
Step 1: Understand storing extra info in HTML
Custom data attributes starting with data- allow storing extra info without affecting display or behavior.
Step 2: Identify the correct attribute for product info
data-product-info is a valid custom data attribute to hold product details invisibly.
Final Answer:
data-product-info -> Option A
Quick Check:
Extra info storage = data-* attributes [OK]
Hint: Use data-* attributes to store hidden info [OK]
Common Mistakes:
Using title which shows visible tooltip
Using hidden which hides element
Using class which is for styling, not data
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.