html登录界面代码实现
时间: 2024-08-28 12:02:07 浏览: 11
HTML登录界面通常包括输入用户名和密码的表单元素,以及提交按钮。下面是一个简单的HTML登录页面的示例代码:
```html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<style>
/* 可选:添加一些基本样式 */
body {
font-family: Arial, sans-serif;
}
.login-form {
width: 300px;
margin: auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="login-form">
<h2>登录</h2>
<form action="/login" method="post">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">登录</button>
<p>还没有账号?<a href="/register">注册</a></p>
</form>
</div>
</body>
</html>
```
在这个例子中,`action`属性指定当用户点击提交按钮时,表单数据将发送到的服务器端处理地址。`required`属性确保输入不是空的。