Suggest an editImprove this articleRefine the answer for “What is an attribute in HTML?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)An **attribute in HTML** is an additional characteristic of a tag that specifies exactly how an element should look, work, or behave. **Key point:** if a tag is "what this is", an attribute is "what it is like, where it is, what it does".Shown above the full answer for quick recall.Answer (EN)ImageAn **attribute in HTML** is an **additional characteristic of a tag** that specifies **exactly how an element should look, work, or behave**. If a tag is *"what this is"*, then an attribute is *"what it is like, where it is, what it does"*. --- ### Example ```html <img src="photo.jpg" alt="My photo" width="300"> ``` Here: - `<img>` is the image tag, - `src="photo.jpg"` is the path to the image file, - `alt="My photo"` is the alternative text if the image fails to load, - `width="300"` is the width of the image in pixels. Everything that goes **inside the opening tag** after its name is an **attribute**. --- ### The structure of an attribute An attribute consists of three parts: ```javascript name = "value" ``` Example: ```html <a href="https://example.com">Link</a> ``` - **attribute name:** `href` - **value:** `"https://example.com"` --- ### Where attributes are written Attributes are always specified **inside the opening tag**: ```html <tagname attribute1="value1" attribute2="value2">Content</tagname> ``` --- ### There are different types of attributes #### 1. **Standard (global)** Can be added to almost any tag: - `id` is a unique identifier of the element; - `class` is a class name for applying styles; - `style` is inline styling; - `title` is a tooltip. Example: ```html <p id="intro" class="text" title="Description">Example paragraph</p> ``` #### 2. **Specific (depend on the tag)** Some attributes only apply to certain tags: - `src`, `alt`, `width`, `height` for `<img>`; - `href`, `target` for `<a>`; - `type`, `value`, `placeholder` for `<input>`. --- ### Attributes without a value Sometimes just the presence of an attribute is enough: ```html <input type="checkbox" checked> ``` Here `checked` means the checkbox is checked by default. --- ### Summary: | Concept | Description | |---|---| | **Attribute** | An additional property of a tag | | **Where it is specified** | Inside the opening tag | | **Format** | `name="value"` | | **What it is for** | To specify the behavior, appearance, or content of an element | --- **In simple terms:** An attribute is an **addition to a tag** that explains to the browser *exactly which element to show and how it should work.* Without attributes, the page would look the same everywhere, without individual settings.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.