html常用代码
创建标题和段落:
html<!DOCTYPE html>
<html>
<head>
<title>标题</title>
</head>
<body>
<h1>主标题</h1>
<h2>副标题</h2>
<p>这是一个段落。</p>
</body>
</html>
创建链接:
html<a href="https://www.example.com">链接文本</a>
创建图像:
html<img src="image.jpg" alt="图像描述">
创建列表:
html<ul>
<li>项目1</li>
<li>项目2</li>
<li>项目3</li>
</ul>
创建表格:
html<table border="1">
<tr>
<th>表头1</th>
<th>表头2</th>
</tr>
<tr>
<td>数据1</td>
<td>数据2</td>
</tr>
</table>
创建表单:
html<form action="/submit" method="post">
<label for="username">用户名:</label>
<input type="text" id="username" name="username"><br><br>
<label for="password">密码:</label>
<input type="password" id="password" name="password"><br><br>
<input type="submit" value="提交">
</form>
这些是 HTML 中最常见的基本元素,你可以根据需要进行组合和修改。
创建按钮:
html<button>按钮文本</button>
创建带有样式的文本:
html<p><strong>加粗文本</strong></p>
<p><em>斜体文本</em></p>
<p><u>下划线文本</u></p>
<p><del>删除线文本</del></p>
插入音频:
html<audio controls>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
插入视频:
html<video width="320" height="240" controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
创建注释:
html<!-- 这是一个注释 -->
创建 div 区块:
html<div>
<!-- 这里是 div 区块的内容 -->
</div>
插入分割线:
html<hr>
创建 iframe:
html<iframe src="https://www.example.com" width="600" height="400"></iframe>
插入脚本:
html<script>
// JavaScript 代码
</script>
这些示例覆盖了 HTML 中的一些基本和常见的元素,你可以根据需要进一步探索和学习。