DEV Community

Parthipan M
Parthipan M

Posted on

ATTRIBUTES IN HTML

HTML Attributes:

HTML attributes are special modifier words placed inside an element's opening tag to provide additional information, configuration, or behavioral changes to that element. They essentially customize how a standard HTML element looks, functions, or interacts with the user.

The Structure of an Attribute

Attributes almost always arrive in name/value pairs and follow a strict structural syntax

  • Attribute Name: Specifies the property you want to set (e.g., href, src, class).

  • Attribute Value: Specifies the actual setting or instruction, which must be enclosed in quotation marks.

example:

<a href="https://www.wikipedia.org" target="_blank">Visit Wikipedia</a>
Enter fullscreen mode Exit fullscreen mode

Common attributes

** Global vs Element-Specific Attributes**

Global attributes work on any HTML element:

Tag and Key Attributes

1.<a>- href, target, rel

  1. <img>- src, alt, width, height

  2. <input>- type, name, placeholder, required

  3. <button>- type, disabled, onclick

  4. <div>- id, class, style

  5. <form>- action, method

  6. <table>- border, cellpadding

  7. <link>- rel, href, type

  8. <script>- src, defer, async

Top comments (0)