HTML attributes are data that can be added to the opening tag of an HTML element. These attributes modify the default behavior of the element or provide additional information about it.
Attributes consist of a name and are usually set equal to a value. Values are enclosed in double or single quotation marks.
The syntax for adding attributes to an HTML element is as follows:
Note: Attribute names are not case-sensitive, but it is good practice to write HTML markup in lowercase.
<img> element, which is commonly used to display images, reveals several attributes, such as
height. These attributes exert significant influence over the manner in which the image appears on the web page. The dimensions of the particular element, once specified, enable precise control over the end result.
<img src="source_of_image.png" width="500" height="600" />
disabled attribute is applied to form elements like buttons and inputs to make them nonfunctional:
This is the output of the above code snippet:
- An HTML attribute used to select one or more elements for the application of styling or logic.
- Sets the direction of the text of an HTML element.
- Used to specify a unique id for an HTML element, which cannot be shared across multiple elements within the same HTML document.
- Specifies the location of a digital source.
- Specifies how an element will be rendered in a web browser.
- Contains and can display the specified information about the element it belongs to.
- Anonymous contributorAnonymous contributor92 total contributions
- hughlilly3 total contributions
- Anonymous contributorAnonymous contributor3077 total contributions
- christian.dinh2481 total contributions
- danieldo191 total contribution