HTML常见标签及用法

HTML常见标签及用法

Posted by Starrynight on 2024-01-27
Estimated Reading Time 5 Minutes
Words 1k In Total
Viewed Times

HTML常见标签及用法

标签 用途 示例代码 常见属性
<div> 块级容器,用于组织内容 <div class="container">内容</div> classidstyle
<span> 行内元素,可用于样式应用 <span style="color:red;">红色文本</span> classidstyle
<p> 定义段落 <p>这是一个段落。</p> classidstyle
<h1> - <h6> 标题标签,<h1> 最大,<h6> 最小 <h1>标题</h1> classid
<a> 超链接 <a href="https://www.example.com" target="_blank">点击跳转</a> hreftarget (_blank_self)、title
<img> 插入图片 <img src="image.jpg" alt="示例图片"> srcaltwidthheight
<ul> / <li> 无序列表 <ul><li>项目1</li><li>项目2</li></ul> classid
<ol> / <li> 有序列表 <ol><li>第一项</li><li>第二项</li></ol> type (1AaIi)
<table> 创建表格 <table border="1"><tr><td>数据</td></tr></table> bordercellpaddingcellspacing
<tr> / <td> 表格行、单元格 <tr><td>单元格</td></tr> colspan(跨列) 、rowspan(跨行)
<th> 表格表头 <th>标题</th> scope (colrow)
<form> 表单 <form action="/submit" method="post"></form> actionmethod (GETPOST)
<input> 输入框 <input type="text" placeholder="请输入内容"> type (textpasswordemail)、namevalue
<textarea> 多行文本输入框 <textarea rows="4" cols="50">默认文本</textarea> rowscolsplaceholder
<button> 按钮 <button type="submit">提交</button> type (submitresetbutton)
<select> / <option> 下拉选择框 <select><option value="1">选项1</option></select> namemultiple
<label> 关联表单控件 <label for="username">用户名</label> for(绑定 inputid
<header> 页面头部 <header>网站标题</header> classid
<footer> 页面底部 <footer>版权所有 &copy; 2025</footer> classid
<main> 主要内容 <main><p>主要内容</p></main> classid
<section> 章节 <section><h2>章节标题</h2></section> classid
<article> 文章 <article><h2>文章标题</h2></article> classid
<aside> 侧边栏 <aside>相关信息</aside> classid
<nav> 导航栏 <nav><a href="/">主页</a></nav> classid
<audio> 插入音频 <audio controls><source src="music.mp3" type="audio/mpeg"></audio> controlsautoplayloop
<video> 插入视频 <video width="320" height="240" controls><source src="movie.mp4" type="video/mp4"></video> controlsautoplayloop
<iframe> 内嵌网页 <iframe src="https://www.example.com"></iframe> srcwidthheight
<canvas> 画布绘图 <canvas id="myCanvas"></canvas> widthheight
<svg> 矢量图形 <svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="black" fill="red"/></svg> widthheight
<mark> 高亮文本 <p>这是<mark>重要的</mark>信息</p> classid
<code> 代码片段 <code>console.log("Hello")</code> classid
<pre> 预格式化文本 <pre>格式化文本</pre> classid
<blockquote> 引用文本 <blockquote>这是引用内容</blockquote> cite
<cite> 引用来源 <cite>《HTML基础》</cite> classid
<abbr> 缩略语 <abbr title="World Health Organization">WHO</abbr> title
<time> 时间 <time datetime="2025-03-05">3月5日</time> datetime
<progress> 进度条 <progress value="50" max="100"></progress> valuemax
<meter> 计量器 <meter value="60" min="0" max="100"></meter> valueminmax


如果您喜欢此博客或发现它对您有用,则欢迎对此发表评论。 也欢迎您共享此博客,以便更多人可以参与。 如果博客中使用的图像侵犯了您的版权,请与作者联系以将其删除。 谢谢 !