Introduction to Data Analysis
Data Analysis |
2025-01-17 20:46:28
HTML attributes provide additional information about HTML elements. They help define properties such as appearance, behavior, and functionality. Attributes always appear within the opening tag of an element and follow the format:
<tagname attribute="value">Content</tagname>
Below is a well-explained guide to all the important HTML attributes, categorized based on their usage.
Global attributes can be used with all HTML elements.
<p id="intro">This is an introduction.</p>
<p class="highlight">This paragraph has a highlight.</p>
<p style="color: red; font-size: 18px;">This text is red.</p>
<p title="Hello!">Hover over this text.</p>
<button data-product-id="123">Add to Cart</button>
<p lang="en">This is in English.</p>
ltr
for left-to-right, rtl
for right-to-left).<p dir="rtl">Ù…Ø±ØØ¨Ø§ بالعالم</p>
<a>
Tag)<a href="https://example.com">Visit Example</a>
_self
(default) → opens in the same tab._blank
→ opens in a new tab._parent
→ opens in the parent frame._top
→ opens in the full body of the window.<a href="https://example.com" target="_blank">Open in new tab</a>
<a href="https://example.com" rel="nofollow">No Follow Link</a>
<a href="file.pdf" download="myfile.pdf">Download PDF</a>
<img>
Tag)<img src="image.jpg" alt="Description of image">
<img src="logo.png" alt="Company Logo">
<img src="photo.jpg" width="300" height="200">
lazy
for deferred loading).<img src="large-image.jpg" loading="lazy">
<form>
, <input>
, <textarea>
, <select>
Tags)<form action="submit.php">
GET
→ Data is sent in the URL.POST
→ Data is sent securely in the request body.<form action="submit.php" method="post">
<input type="text" placeholder="Enter your name">
<input type="text" value="John Doe">
<input type="email" required>
<input type="text" value="Fixed Value" readonly>
<input type="text" disabled>
<input type="text" maxlength="10" minlength="3">
<input type="text" pattern="[A-Za-z]+">
<input type="file" multiple>
<table>
, <th>
, <td>
Tags)<table border="1">
<td colspan="2">Merged Columns</td>
<td rowspan="2">Merged Rows</td>
<audio>
, <video>
Tags)<audio src="music.mp3" controls></audio>
<video src="movie.mp4" controls></video>
<video src="clip.mp4" autoplay></video>
<video src="loop.mp4" loop></video>
<video src="silent.mp4" muted></video>
<button>
Tag)submit
→ Submits form.reset
→ Resets form.button
→ Regular button.<button type="submit">Submit</button>
<button disabled>Cannot Click</button>
<button aria-label="Close">X</button>
<div role="alert">Warning Message</div>
<button onclick="alert('Hello!')">Click Me</button>
<p onmouseover="this.style.color='blue'">Hover to change color.</p>
HTML attributes enhance elements by adding interactivity, styling, and functionality. Understanding these attributes allows developers to build efficient, accessible, and user-friendly websites.