Tag and attribute names in ordinary HTML are generally case-insensitive, but values follow different rules. For example, a file path or script selector can depend on the exact spelling.
What You Need to Know
Choose lowercase tag names, lowercase attribute names, and consistent file naming. Keep capitalization in values when it matters, including names that come from users.
Example: See It in Action
Try this markup in a fresh practice file. The next section explains the parts worth paying attention to.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<section CLASS="notice">
<p dir="rtl">Right-to-left example</p>
<p lang="en">English text</p>
</section>
Let’s Understand the Example
- Section groups content around a shared topic and usually has a heading.
- A p groups a paragraph of related text. Start another paragraph for a new thought.
- Class is a reusable label for styling or scripts; several elements may share the same class.
- Dir tells the browser which direction the text runs.
- Lang tells tools which language the text uses, helping pronunciation and language-aware features.
Look for the text “Right-to-left example” in the page. If the visible result surprises you, inspect the rendered elements to see what the browser actually built.
What Should You See?
The page should include “Right-to-left example”. 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
- Compare the meaning of a tag name with the value of a class or id attribute.
- 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
- Assuming name="Email" and name="email" will always be treated as the same form field.
- Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.
Key Takeaways
- Tag and attribute names in ordinary HTML are generally case-insensitive, but values follow different rules.
- Section groups content around a shared topic and usually has a heading.
- Choose lowercase tag names, lowercase attribute names, and consistent file naming. Keep capitalization in values when it matters, including names that come from users.