html简单代码
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>简单HTML页面</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
header {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
section {
padding: 20px;
margin: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>欢迎来到我的网站</h1>
</header>
<section>
<h2>简单HTML页面示例</h2>
<p>这是一个简单的HTML页面示例,用于演示基本的HTML结构和样式。</p>
</section>
<footer>
<p>© 2024 我的网站</p>
</footer>
</body>
</html>
这个示例包含了一个简单的网页结构,包括了一个标题、一个段落和一个页脚。CSS 部分定义了基本的样式,包括背景色、字体和布局。
好的,接着在这个简单的 HTML 页面中,我们可以添加更多的内容和功能,比如:
链接和图像:添加链接到其他页面或外部网站,以及在页面上显示图像。
html<section>
<h2>链接和图像示例</h2>
<p>这是一个带有链接和图像的示例。</p>
<a href="https://www.example.com">点击这里访问示例网站</a>
<br>
<img src="example-image.jpg" alt="示例图像">
</section>
表单:创建一个简单的表单,用于收集用户输入信息。
html<section>
<h2>表单示例</h2>
<form action="submit.php" method="post">
<label for="name">姓名:</label>
<input type="text" id="name" name="name" required>
<br>
<label for="email">邮箱:</label>
<input type="email" id="email" name="email" required>
<br>
<input type="submit" value="提交">
</form>
</section>
列表:展示有序或无序列表。
html<section>
<h2>列表示例</h2>
<h3>无序列表:</h3>
<ul>
<li>项目1</li>
<li>项目2</li>
<li>项目3</li>
</ul>
<h3>有序列表:</h3>
<ol>
<li>第一步</li>
<li>第二步</li>
<li>第三步</li>
</ol>
</section>
响应式设计:使用媒体查询实现响应式设计,使网页在不同设备上呈现良好的外观。
html<style>
/* 添加媒体查询 */
@media (max-width: 600px) {
body {
font-size: 14px;
}
section {
padding: 10px;
margin: 10px;
}
}
</style>
这些是一些可用于扩展简单 HTML 页面的示例。您可以根据需要添加更多的内容和功能。