Attributes are extra settings written inside a start tag. The name tells the browser what setting you mean; the value provides its information, such as the destination in href.
What You Need to Know
Quotes make values safe and easy to read, especially when they contain spaces. Write values in double quotes as a consistent habit, even when HTML allows other forms.
The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.
Example: See It in Action
Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<a href="about.html" title="Read about this website">
About this website
</a>
<p id="welcome">Welcome!</p>
Let’s Understand the Example
- An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
- A p groups a paragraph of related text. Start another paragraph for a new thought.
- Href contains the destination of a link. A value starting with # points to an id on the same page.
- Title adds advisory information, but it is not a substitute for readable visible labels.
- Id gives one element a unique name within the page, so a link, label, or script can point to it.
The first example link points to about.html. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.
What Should You See?
The page should include “About this website”. If it looks different from what you expected, open developer tools and compare the source with the elements the browser created.
Try removing one piece of markup in a scratch copy, refresh the page, and compare the behavior. This is often the fastest way to understand what that piece contributes.
Try It Yourself
- Add a class attribute and update the link's title without changing its destination.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Putting href in a closing tag or forgetting quotes around a value with spaces.
- Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.
Key Takeaways
- Attributes are extra settings written inside a start tag.
- An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
- Quotes make values safe and easy to read, especially when they contain spaces. Write values in double quotes as a consistent habit, even when HTML allows other forms.