可以形成样式做没有表? [英] Can form styling be done without tables?

查看:76
本文介绍了可以形成样式做没有表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已习惯于使用< table> s 来完全调整表单域。这是我通常写我的形式:

 < table border =0> 
< tr>
< td>< label for =f_name>名字:< / label>< / td>
< td>< input type ='text'id ='f_name'name ='f_name'/>< / td>
< td class ='error'><?= form_error('f_name');?>< / td>
< / tr>
< / table>

我知道这是不好的做法,我想使用css, < label> s < div> s 然而,事实是,< table> s 对于表单非常好。



我最近尝试使用< dt>

/ code>和< dd> 标签,但我最终还是回到表格,因为它们看起来更好。

$

解决方案

div>

这可能得不到很多支持,但这是我的两分钱:



在某些情况下,表格更容易例如三个列或表单(虽然在这里有一些很好的建议做一个纯CSS表单布局,所以不要忽视这些。)

进程和方法可以成为良好的仆人,但是是主人。 
- 软件安全评估的艺术中的Mark Dowd,John McDonald和Justin Schuh

这个引语非常强烈地适用于这种情况。



如果你的表格布局为你工作,不会导致辅助功能问题,并且不会损坏 - 必须,总是 - 让我害怕,因为一个大小不适合所有!带上一粒盐的狂热分子。


I've gotten used to using <table>s for aligning my form fields perfectly. This is how I commonly write my forms:

<table border="0">
   <tr>
     <td><label for="f_name">First name:</label></td>
     <td><input type='text' id='f_name' name='f_name' /></td>
     <td class='error'><?=form_error('f_name');?></td>
   </tr>
</table>

I know this is bad practice, and I want to use css, <label>s, <div>s, or a cleaner method. However, the fact is, <table>s work extremely well for the forms. Everything is aligned exactly right, the spacing is perfect, all errors exactly below each other, etc.

I recently tried using <dt> and <dd> tags for a form, but I ended up reverting back to tables just because they looked so much better.

Is there any hope for people like me, or are tables just the best way to create forms?

解决方案

This might not get a lot of support but here's my two cents:

In some situations tables are easier for layout; such as three columns or forms (albeit there are some great suggestions here for doing a pure css form layout so don't ignore those either.)

Processes and methodologies can make good servants but are poor masters.
   - Mark Dowd, John McDonald & Justin Schuh 
     in "The Art of Software Security Assessment"

I believe that this quote very strongly applies to this situation. If your table layout is working for you, not causing accessibility issues and isn't broken - then don't fix it.

Phrases like: "you should", "must", "always" - make me scared, because one-size-doesn't-fit-all! Take zealots with a grain of salt.

这篇关于可以形成样式做没有表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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