在 html 中显示表单时使用表格标签是不是设计不好? [英] Is it bad design to use table tags when displaying forms in html?

查看:23
本文介绍了在 html 中显示表单时使用表格标签是不是设计不好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直听说 div 标签应该用于布局目的而不是 table 标签.那么这也适用于表单布局吗?我知道表单布局仍然是一种布局,但似乎使用 div 来创建表单布局需要更多的 htmlcss.所以考虑到这一点,表单布局应该使用 div 标签吗?

解决方案

是的,它确实适用于表单布局.请记住,还有诸如 FIELDSET 和 LABEL 之类的标签,它们专门用于向表单添加结构,因此这不是仅使用 DIV 的问题.您应该能够用非常少的 HTML 标记表单,让 CSS 完成其余的工作.例如:

<div><label for="nameTextBox">名称:</label><input id="nameTextBox" type="text"/>

...</fieldset>

I keep hearing that div tags should be used for layout purposes and not table tags. So does that also apply to form layout? I know a form layout is still a layout, but it seems like creating form layouts with divs requires more html and css. So with that in mind, should forms layouts use div tags instead?

解决方案

Yes, it does apply for form layouts. Keep in mind that there are also tags like FIELDSET and LABEL which exist specifically for adding structure to a form, so it's not really a question of just using DIV. You should be able to markup a form with pretty minimal HTML, and let CSS do the rest of the work. E.g.:

<fieldset>
    <div>
         <label for="nameTextBox">Name:</label>
         <input id="nameTextBox" type="text" />
    </div>
    ...
</fieldset>

这篇关于在 html 中显示表单时使用表格标签是不是设计不好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆