Ctrl /

HTML Attributes

HTML attributes provide additional information about HTML elements. They help modify the behavior or appearance of a tag.

What are HTML Attributes

Attributes are always written inside the opening tag. An attribute usually contains an Attribute name and an Attribute value.

<tag attribute="value">Content</tag>

Example:

<a href="https://code4utech.com">Visit CODE4UTECH</a>

Explanation:

  • href is the attribute
  • https://code4utech.com is the value
  • The attribute tells the browser where the link should go when clicked.

Common HTML Attributes

href Attribute

Used with the anchor tag to define a link.

<a href="https://code4utech.com">Visit CODE4UTECH Website</a>

When the user clicks the link, they will be redirected to the CODE4UTECH website.

src Attribute

Used with image tags to define the image source.

<img src="images/code4utech-office.jpg">

This tells the browser where the image file is located.

alt Attribute

The alt attribute provides alternative text if an image cannot load. It also helps improve accessibility and SEO.

<img src="code4utech-logo.png" alt="CODE4UTECH Company Logo">

id Attribute

The id attribute uniquely identifies an element. This ID can later be used in CSS or JavaScript.

<h1 id="company-name">CODE4UTECH CONSULTANCY PVT. LTD.</h1>

class Attribute

The class attribute is used to apply styles to multiple elements. Classes are commonly used in CSS frameworks like Tailwind CSS.

<p class="service-text">CODE4UTECH provides professional web development services.</p>