一个完整的html代码
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我的网页</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
margin-top: 50px;
}
h1 {
color: #333;
text-align: center;
}
p {
color: #666;
line-height: 1.6;
}
</style>
</head>
<body>
<div class="container">
<h1>欢迎来到我的网页</h1>
<p>这是一个简单的HTML页面示例。您可以在这里添加更多内容,包括文字、图片、链接等等。</p>
</div>
</body>
</html>
这个HTML代码包含了一个基本的HTML结构,包括<html>、<head>、<title>、<meta>、<body>等标签。在页面中,有一个标题和一段简单的文本内容,同时包含了一些基本的CSS样式来美化页面外观。
接下来,我会为你添加一个简单的图像和链接到上面的HTML代码中。
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我的网页</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
margin-top: 50px;
}
h1 {
color: #333;
text-align: center;
}
p {
color: #666;
line-height: 1.6;
}
img {
display: block;
margin: 0 auto;
max-width: 100%;
height: auto;
border-radius: 5px;
margin-top: 20px;
}
a {
display: block;
text-align: center;
color: #007bff;
text-decoration: none;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>欢迎来到我的网页</h1>
<p>这是一个简单的HTML页面示例。您可以在这里添加更多内容,包括文字、图片、链接等等。</p>
<img src="https://via.placeholder.com/400" alt="占位图">
<a href="https://www.example.com">点击这里访问示例链接</a>
</div>
</body>
</html>
这个更新的HTML代码增加了一个图片和一个链接。图片的src属性指向一个占位图像URL,链接指向一个示例网址。样式也稍作调整,以确保图像和链接居中显示并具有一定的间距。