引言
HTML(HyperText Markup Language)是网页制作的基础,掌握HTML是成为一名优秀网页设计师或前端开发者的关键。本文将提供一系列HTML实战练习题,旨在帮助读者从零开始,通过实际操作提升网页制作技能。
实战练习题
1. 创建一个简单的网页
目标:了解HTML的基本结构。
任务:创建一个包含标题、段落、图片和链接的简单网页。
代码示例:
<!DOCTYPE html>
<html>
<head>
<title>我的第一个网页</title>
</head>
<body>
<h1>欢迎来到我的网页</h1>
<p>这是一个简单的段落。</p>
<img src="image.jpg" alt="示例图片">
<a href="https://www.example.com">访问示例网站</a>
</body>
</html>
2. 使用表格展示数据
目标:掌握HTML表格的使用。
任务:创建一个表格,展示学生信息。
代码示例:
<table border="1">
<tr>
<th>姓名</th>
<th>年龄</th>
<th>班级</th>
</tr>
<tr>
<td>张三</td>
<td>20</td>
<td>计算机科学与技术1班</td>
</tr>
<tr>
<td>李四</td>
<td>21</td>
<td>计算机科学与技术2班</td>
</tr>
</table>
3. 使用表单收集用户信息
目标:了解HTML表单的使用。
任务:创建一个表单,收集用户姓名、邮箱和密码。
代码示例:
<form action="submit.php" method="post">
<label for="name">姓名:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="email">邮箱:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required><br><br>
<input type="submit" value="提交">
</form>
4. 使用CSS美化网页
目标:了解CSS的基本使用。
任务:为上述网页添加CSS样式,美化页面。
代码示例:
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
h1 {
color: #333;
}
table {
margin: 20px 0;
border-collapse: collapse;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
}
form {
margin: 20px 0;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"], input[type="email"], input[type="password"] {
width: 100%;
padding: 8px;
margin-bottom: 10px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
}
</style>
总结
通过以上实战练习题,读者可以逐步掌握HTML的基本知识和技能。在实际操作过程中,请多加练习,不断优化和提升自己的网页制作能力。祝您学习愉快!
