HTML Attribute


Further details about HTML elements can be found in the HTML attributes. They are used to configure or change an element's behavior and are always included in the opening tag. An equal sign (=) divides the name and value that make up an attribute, and either double or single quotes surround the value.

An overview of HTML attributes is provided below:

Syntax:

Example:

1. Anchor Tag (Href Attribute - <a>):-

  •  Provides the URL for the resource that is linked.

2. Src Attribute (Image Tag- <img> ):- 

  • Indicates the image's source URL.

3. Alt Attribute (Image Tag - <img> ):-

  •  Offers a substitute text for the image, shown in the event that it is unable to load.

4. Style Attribute (Various Tags):- 

  • Defines an element's inline CSS styles.

5. Class Attribute (Various Tags):- 

  • Gives an element one or more class names, which can be utilized for JavaScript element identification or CSS styling.

6. Id Attribute (Various Tags):- 

  • Provides an element with a unique identifier that can be utilized for scripting or styling.

7. Width and Height Attributes( Image Tag <img> ) :- 

  • Provides information about the width and height of an image.

8. Checked Attribute (Input Tag <input> ):- 

  • Denotes the need to pre-select a checkbox or radio button.

9. Disabled Attribute ( Input Tag <input> ):- 

  • Disables an input element, rendering it non-interactive.

10. Placeholder Attribute (Input Tag <input>):-

  • An input field's expected value is briefly described by this placeholder attribute.


These are but a handful of the attributes found in HTML. Understanding how to use them enables developers to control the look and behavior of elements on a webpage. Different HTML elements support different attributes. To find out what attributes a particular HTML element supports, always consult its documentation.


Post a Comment

Previous Post Next Post

Popular Items

HTML Table Sizes :

HTML Fevicons

CSS Syntax :