简体   繁体   English

CSS格式会影响表格的有效性吗

[英]Does css formatting affect validity of forms

If I have a HTML form with some embedded div s, and after the CSS is applied the sections of the form end up spread all over the page outside of the original <form> boundaries, does/will the form continue to work. 如果我有一个带有一些嵌入式div的HTML表单,并且在应用CSS之后,表单的各个部分最终会散布在整个原始<form>边界之外的页面上,该<form>是否/将继续工作。 What do the HTML specs say about this kind of thing? HTML规范对这种事情怎么说?

Yes, the form will continue to work. 是的,该表格将继续有效。 CSS positioning does not affect the validity of the HTML. CSS定位不会影响HTML的有效性。 The only concern is usability or clarity. 唯一关心的是可用性或清晰度。 If it is not apparent that an element belongs to the form you might confuse the users. 如果不清楚元素属于表单,则可能会使用户感到困惑。 Or, if you position/layer something where it can't be clicked that will cause problems as well. 或者,如果您在无法单击的位置放置/分层也会导致问题。

But HTML and CSS are separate things... the HTML specs have nothing to say in this matter. 但是HTML和CSS是分开的东西……HTML规范对此无话可说。

As long as the elements are still children of the form tags, nothing will change. 只要元素仍然是form标签的子元素,什么都不会改变。 The display does not effect the functionality, so it doesn't matter if they do not appear to be in the same area as the form. 该显示不会影响该功能,因此,如果它们看起来与表单不在同一区域,则无所谓。

However, if you were manipulating the DOM via javascript and moved the elements out of the form, (by outside of the form, I mean that they are no longer child elements of that form, not that they are visually outside), then they wouldn't be submitted with that form anymore. 但是,如果您通过javascript处理DOM并将元素移出表单,(在表单外部,我的意思是它们不再是该表单的子元素,而是在视觉上不在外部),那么它们将不再与该表格一起提交。

Positioning has no effect. 定位无效。 Nesting of the tags does. 标签的嵌套确实如此。 All form elements need to be inside the but I think that's the only requirement. 所有表单元素都必须位于内,但我认为这是唯一的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM