๐ HTML Anchor Elements & Attributes
๐งฑ Structure of an Anchor Tag
But this alone won’t work as a link. We need to add an attribute.
⚙️ What is an Attribute?
An attribute gives extra information to an HTML element.
✅ Attributes are always added inside the opening tag.
Example:
Here:
-
hrefis the attribute name. -
"https://example.com"is the value. -
Together, they tell the browser where the link should go.
๐ Specific vs Global Attributes
-
Specific Attribute (e.g., href): Only works with certain tags like
<a>. -
Global Attribute (e.g., draggable): Can be used with any HTML tag.
Example:
✅ Challenge Task: Top 5 Favorite Websites
You can create a list of your favorite websites using an ordered list and anchor tags.
Example:
This will show a numbered list of clickable links.
๐ข Bonus Tip: Start List From a Specific Number
You can change the starting number of an ordered list using the start attribute:
This will start the list from 5 instead of 1.
✍️ What Did We Learn?
-
Anchor tags (
<a>) create links. -
Attributes like
hreftell the link where to go. -
Some attributes are specific, some are global.
-
We can combine anchor tags with lists for fun projects.
-
Always use quotes around attribute values.

Comments
Post a Comment