注册表单页面
下面是一个基础的注册表单页面示例,包含常见的输入字段和提交按钮,并带有简单的 HTML5 表单验证。
HTML 代码示例
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>注册表单</title>
<style>
body {
font-family: "Microsoft YaHei", sans-serif;
max-width: 400px;
margin: 50px auto;
padding: 20px;
background: #f7f7f7;
border: 1px solid #ddd;
border-radius: 6px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 6px;
font-weight: bold;
color: #555;
}
input[type="text"],
input[type="email"],
input[type="password"] {
padding: 8px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
}
button {
padding: 10px;
background-color: #3498db;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<h1>用户注册</h1>
<form action="/submit-registration" method="POST">
<label for="username">用户名</label>
<input
type="text"
id="username"
name="username"
required
minlength="3"
maxlength="20"
placeholder="请输入用户名"
/>
<label for="email">邮箱</label>
<input
type="email"
id="email"
name="email"
required
placeholder="请输入邮箱地址"
/>
<label for="password">密码</label>
<input
type="password"
id="password"
name="password"
required
minlength="6"
placeholder="请输入密码"
/>
<label for="confirm-password">确认密码</label>
<input
type="password"
id="confirm-password"
name="confirm-password"
required
minlength="6"
placeholder="请再次输入密码"
/>
<button type="submit">注册</button>
</form>
</body>
</html>
相关内容
- 什么是 HTML HTML 是构建网页的基础语言,用于定义网页的结构和内容。通过标签,HTML 可以组织文本、图片、链接和其他多媒体元素,使网页能够被浏览器正确解析和显示。学习...
- HTML 页面结构 HTML 页面结构是网页内容的骨架,通过合理使用标签组织页面的不同部分,如头部、主体和底部。掌握页面结构有助于创建语义清晰、易于维护和SEO友好的网页,提高用户...
- 编辑器推荐 推荐适合 HTML 开发的编辑器,包括功能强大的代码高亮、智能提示和调试工具,帮助开发者提高编码效率和代码质量。无论是初学者还是专业开发者,都能找到合适的编辑器...
- 第一个 HTML 页面 创建第一个 HTML 页面是学习网页开发的第一步,通过编写简单的结构化代码,理解网页基本组成及浏览器如何解析显示内容,打下坚实基础。
- 标题与段落 标题与段落是 HTML 中最基本的文本结构元素,用于组织和展示内容的层次关系。掌握它们有助于提高网页的可读性和结构清晰度。
- 文本格式化 文本格式化是 HTML 中用于丰富和美化文字内容的技术,包括加粗、斜体、删除线、上下标等多种样式,提升网页的可读性和表现力。