HTML Attributes

HTML attributes serve to specify the features of an HTML element. They're included in the opening tag of the element and match of two factors:

Types of HTML Attributes

There are three primary orders of HTML attributes:

Core Attributes

These Beginner attributes can be employed across utmost HTML elements. Common for Example include:

Root Attributes

These attributes help in setting the document for different languages and regions. For example:

General Attributes

These attributes provide additional information about the element but don’t necessarily impact its appearance or functionality. Example:

Most Common Core Attributes

Core attributes are among the most frequently used in HTML, and they include four main types:

learning HTML attributes helps you enhance functionality, styling, and association in your web development systems!

ID specialty

The ID specialty assigns a unique identifier to an HTML element. Each element with an ID has its own distinct identity, analogous to how every person has a unique identity. No two elements can take the same ID.

Example


          <p id="html-attributes">This is an HTML ID Attributes.</p>
          <p id="html-paragraph">This is an HTML ID Attributes.</p>
     

In this example, the ID Attributes differentiates the two paragraphs by assigning them distinct values html-attributes and html-paragraph.

Class Attribute

The class Attributes connects an HTML element to a specific class, frequently for styling (CSS) or JavaScript relations. Unlike the ID Attributes, multiple elements can take the same class.


          <p class="note">This is an HTML CLASS Attributes.</p>
          <p class="note">This is another HTML CLASS Attributes.</p>
     

Title Attributes

The title Attributes provides unnecessary information about an element. When you hang over the element, a tooltip appears displaying the title textbook.

Example


          <p title="Hello, Coders">This is TITLE Attributes.</p>
     

Case: When you hang over this title, a tooltip saying "Hello, Coders" appears.

Preview :

title attributes image

Style Attributes

The style Attributes allows for inline styling within HTML elements. It applies CSS section directly to individual elements in the HTML Tag.

Example


          <p style="color:blue; font-size:18px;">This textbook is blue and has a font size of 18px.</p>
     

Case: The paragraph textbook appears in blue with a font size of 18px.

HTML Attribute Case Sensitivity

HTML is n't case-sensitive for Attributes names, meaning the following variations are treated the same:

Example


          <h1 ID="main-title">This is a title.</h1>
          <p CLASS="main-paragraph">This is a paragraph.</p>
          <button OnClick="alert('Clicked!')">Click Me!</button>
     

Case: The title, paragraph, and button will all work typically despite different case exercises.

Stylis Practice

While HTML allows different cases, it's recommended to use lowercase for attributes (e.g., id rather of ID) to maintain readability and follow W3C rules.