表单怎么用P标签换行
时间: 2023-07-03 17:07:47 浏览: 44
表单中的文本内容可以使用`<br>`标签换行,也可以使用CSS样式属性`display:block;`或`display:inline-block;`将表单元素转换为块级元素或内联块级元素,从而实现换行效果。
例如:
```html
<form>
<label for="username">用户名:</label>
<input type="text" id="username"><br>
<label for="password">密码:</label>
<input type="password" id="password"><br>
<input type="submit" value="登录">
</form>
```
以上代码中使用了`<br>`标签实现换行效果。
另外,也可以使用CSS样式:
```html
<form>
<label for="username" style="display:block;">用户名:</label>
<input type="text" id="username" style="display:inline-block;"><br>
<label for="password" style="display:block;">密码:</label>
<input type="password" id="password" style="display:inline-block;"><br>
<input type="submit" value="登录">
</form>
```
以上代码中使用了`display:block;`和`display:inline-block;`样式属性实现换行效果。