Skip to content
doubtly

2 answers

An attribute gives extra information about an HTML element and is written in the opening tag as name="value".

<a href="https://example.com" target="_blank">Visit</a>
<img src="logo.png" alt="Logo" width="100">
  • Elements can have attributes; many elements are used without any.
  • Attributes are always placed in the start tag, never in the end tag.
  • Most are name/value pairs; values are usually written in quotes.
  • Some are boolean and need no value: disabled, checked, required.

Global attributes used on almost any element: id, class, style, title, lang. Element-specific ones include href (a), src and alt (img), type (input).

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.