W3C-重叠表单和 div 标签的验证问题
我在使用 W3 验证器验证此代码时遇到问题。 问题出在
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="sv" xml:lang="sv" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Title</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="headerwrapper">
<div class="header alignleft">
<a href="index.html">Home</a>
</div>
<div class="header alignright">
<div id="searchfield">
Search
</div>
</div>
<div id="menu">
Menu
</div>
</div>
<div class="clear"></div>
<div class="content">
<div class="box alignleft">
<div class="boxtop"></div>
<div class="boxmiddle">
<form action="links.php" method="post"><input type="hidden" name="edit_page_check" value="yes" />
<p>
<span id="page_leftbox">Text</span>
</p>
</div>
<div class="boxbottom"></div>
</div>
<div class="column580 alignright">
<div class="header580">
<h2>Topic</h2><span class="headerdesc">Text</span>
</div>
<p>
<span id="page_info">Info</span>
</p>
</form>
<br/>
<div id="addlinkform" style="display: none;">
Form2
</div>
<div id="linkform" style="display: none;">
Form3
</div>
</div>
</div>
<div class="clear"></div>
<div class="divider800"></div>
<div id="footer">
Footer text
</div>
</div>
</body>
</html>
I'm having problems with validating this code with the W3 validator.
The problem is with the <form>
tag.
I need the <form>
tag to overlap several <div>
and <span>
tags because I have many different input fields and such, but I'm also using the Form2 and Form3 with input fields and such so I need to use </form>
before the Form2. But this gives me problems when validating because it's overlapping <div>
and <span>
tags.
What can I do to make the validation work?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="sv" xml:lang="sv" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Title</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="headerwrapper">
<div class="header alignleft">
<a href="index.html">Home</a>
</div>
<div class="header alignright">
<div id="searchfield">
Search
</div>
</div>
<div id="menu">
Menu
</div>
</div>
<div class="clear"></div>
<div class="content">
<div class="box alignleft">
<div class="boxtop"></div>
<div class="boxmiddle">
<form action="links.php" method="post"><input type="hidden" name="edit_page_check" value="yes" />
<p>
<span id="page_leftbox">Text</span>
</p>
</div>
<div class="boxbottom"></div>
</div>
<div class="column580 alignright">
<div class="header580">
<h2>Topic</h2><span class="headerdesc">Text</span>
</div>
<p>
<span id="page_info">Info</span>
</p>
</form>
<br/>
<div id="addlinkform" style="display: none;">
Form2
</div>
<div id="linkform" style="display: none;">
Form3
</div>
</div>
</div>
<div class="clear"></div>
<div class="divider800"></div>
<div id="footer">
Footer text
</div>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
XHTML 不允许您重叠标签。例如,这是无效的:
您要做的是,不要试图只包含您认为表单中的项目,而是包含
标签其形式及其容器。例如,您的代码应该如下所示:
注意表单元素如何跨越所有输入标记的容器。
XHTML doesn't let you overlap tags. For example, this is invalid:
What you're going to want to do is, rather than trying to only encompass the items that you believe are in the form, encompass the
<input />
tags that are in the form as well as their containers. For instance, your code should look like this instead:Notice how the form element spans ALL of the input tags' containers.
XML(在本例中为 XHTML)需要格式良好。看看这个。您应该能够通过在树中向上移动
而不是
执行以下操作(将
form
元素向上移动,以便它包装输入及其容器):XML (XHTML in this case) needs to be well-formed. Take a look at this. You should be able to fix that problem by moving the
<form>
-tag up in the tree.Instead of
do the following (move the
form
element up, so that it wraps the inputs as well as their containers):