id: 给元素一个唯一的标识符,可以用于 CSS 选择器或 JavaScript 操作。
<div
id="header">This is a header</div>
class: 给元素指定一个或多个类名,方便通过 CSS 或 JavaScript 操作。
<p
class="text-muted">This is a paragraph.</p>
style: 直接为元素定义 CSS 样式。
<span
style="color: red;">This text is red.</span>
href: 用于 <a> 标签,指定链接目标。
<a
href="https://www.example.com">Visit Example</a>
src: 用于 <img> 和 <script> 标签,指定资源的路径。
<img
src="image.jpg"
alt="Description">
alt: 用于 <img> 标签,提供图片的替代文本。
<img
src="logo.png"
alt="Company Logo">
title: 提供关于元素的额外信息,通常在鼠标悬停时显示。
<button
title="Click me">Submit</button>
name: 在 <input>, <form>, <select> 等表单元素中使用,定义元素的名称。
<input
type="text"
name="username">
value: 定义表单元素的值。
<input
type="text"
value="Default text">
target: 用于 <a> 标签,指定链接的打开方式(如 _blank 在新窗口中打开)。
<a
href="https://www.example.com"
target="_blank"
rel="noopener">Open in new tab</a>
type: 指定表单元素的类型(如 text, password, submit)。
<input
type="password"
name="password">
placeholder: 为 <input> 和 <textarea> 提供一个占位符文本。
<input
type="text"
placeholder="Enter your name">