A small piece of HTML can change what a visitor sees or how the browser understands a page. In this lesson, you will explore is attribute: customized built-in element overview using a short example that you can inspect and change.
The Idea in Plain English
Customized built-in elements use an is attribute on existing tags together with a matching custom element registration. Their browser support is limited compared with autonomous custom elements.
You can test this using a small local HTML file. Change one part at a time and check the result in the browser before adding more code.
A Working Example
Read the sample once before copying it. Notice the element names and attribute values, then compare them with the explanation below.
<!-- Progressive enhancement only; ordinary button remains useful. -->
<button is="fancy-button" type="button">Save</button>
What Each Part Does
- A button performs an action; type="submit" can submit its form.
- type chooses the relevant kind of script, input, media or embedded object.
A supported browser may upgrade the original built-in element while retaining its native role.
Keep the example small while learning. Once it behaves as expected, try it inside a larger page and make sure the URLs, files and surrounding HTML are correct.
Try It Yourself
Try this next: show intended is= example and fallback considerations. Then inspect the page and explain what changed.
Common Beginner Mistakes
- Assuming customized built-ins work on every major browser or that is alone defines behavior.
- Changing several parts of the example at once, making it difficult to see which part caused a different result.
- Choosing a tag only because its default appearance looks right, without checking whether it describes the content correctly.
Key Takeaways
- Customized built-in elements use an is attribute on existing tags together with a matching custom element registration. Their browser support is limited compared with autonomous custom elements.
- A supported browser may upgrade the original built-in element while retaining its native role.
- Test the markup in a browser, and check accessibility and real-world behavior where relevant.