TOP CATEGORIES

×

How to use HTML attributes?

S

Shwati Rana

Use of HTML Attributes

  • Identify the HTML element to which you want to add an attribute.
  • Determine the appropriate attribute for the element based on its intended functionality or purpose.
  • Add the attribute within the start tag of the element, specifying the attribute name and its corresponding value.
  • If the attribute requires a value, enclose the value in quotation marks (" or ').

There are some HTML attributes that are commonly used when we designed an HTML page

  • Class
  • ID
  • Style
  • SRC
  • Alt
  • Disabled
  • Placeholder

CLASS

<div class="container">

  <!-- Element content -->

</div>

ID

<h1 id="title">Hello, World!</h1>

STYLE

<p style="color: red; font-size: 16px;">This is a red paragraph with a font size of 16 pixels.</p>

SRC

<img src="images/picture.jpg" alt="A beautiful picture">

HREF

<a href="https://www.example.com">Visit Example.com</a>

alt

<img src="images/picture.jpg" alt="A beautiful picture">

Disabled

<input type="text" disabled>

Placeholder

<input type="text" placeholder="Enter your name">

1 votes

Your Answer

Email: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)