[英]Element 'div' cannot be nested within element 'ul'
<ul>
<div style="float:left">
<asp:LinkButton ID="lbtnFirst" runat="server" CausesValidation="false" OnClick="lbtnFirst_Click">İlk</asp:LinkButton></div>
<div style="float:left"><asp:LinkButton ID="lbtnPrevious" runat="server" CausesValidation="false" OnClick="lbtnPrevious_Click"> << </asp:LinkButton></div>
</ul>
In my Asp.net project I get this Warning : 在我的Asp.net项目中,我收到此警告:
Validation (XHTML 1.0 Transitional): Element 'div' cannot be nested within element 'ul'.
验证(XHTML 1.0 Transitional):元素'div'不能嵌套在元素'ul'中。
But when I click F5 everthing woks great. 但是,当我点击F5外翻炒锅时很棒。 Now I am working on localhost in Visual Studio 2013 (Code side is C#) I want to ask can this make problem for my site in future ?
现在我正在使用Visual Studio 2013中的localhost(代码端是C#)我想问这可能会在将来为我的网站带来问题吗?
The warning is, well, a warning. 警告是一个警告。 Your page is displayed correctly only because the browser is not too strict on the HTML rules, but that may change in the future.
您的页面显示正确只是因为浏览器对HTML规则不是太严格,但将来可能会更改。 For that reason, you should try to keep your HTML compliant and take the warnings seriously.
因此,您应该尝试保持HTML兼容并严肃对待警告。 In this case, I would suggest to replace the
<div>
with <li>
tags and style them to prevent the margins and bullets (I assume that's why you're using <div>
instead of <li>
in the first place). 在这种情况下,我建议用
<li>
标签替换<div>
并设置它们以防止边距和子弹(我假设这就是为什么你首先使用<div>
而不是<li>
)。
To achieve what you want, apply this CSS style to your list: 要实现您的目标,请将此CSS样式应用于您的列表:
.your-ul {
list-style: none;
}
.your-ul li {
position:relative;
margin-left: 0;
display: inline-block;
}
Your HTML/ASPX code would look like this: 您的HTML / ASPX代码如下所示:
<ul class="your-ul">
<li><asp:LinkButton ID="lbtnFirst" runat="server" CausesValidation="false" OnClick="lbtnFirst_Click">Ilk</asp:LinkButton></li>
<li><asp:LinkButton ID="lbtnPrevious" runat="server" CausesValidation="false" OnClick="lbtnPrevious_Click"> << </asp:LinkButton></li>
</ul>
Normally one would expect a ul
element to contain li
elements. 通常人们会期望
ul
元素包含li
元素。 It may make sense for the li
elements to contain div
s but it doesn't make a lot of sense to have div
s (or anything else) as immediate children of a ul
. li
元素包含div
可能是有意义的,但将div
(或其他任何东西)作为ul
直接子ul
并没有多大意义。 You could change your div
s to li
s, perhaps that's what you're looking for? 你可以将你的
div
改为li
s,也许这就是你要找的东西?
You can still use your div tag, it just needs to be wrapped in a li
element. 您仍然可以使用div标签,它只需要包含在
li
元素中。
<ul>
<li>
<div style="float:left">
<asp:LinkButton ID="lbtnFirst" runat="server" CausesValidation="false" onClick="lbtnFirst_Click">İlk</asp:LinkButton>
</div>
<div style="float:left">
<asp:LinkButton ID="lbtnPrevious" runat="server" CausesValidation="false" OnClick="lbtnPrevious_Click"> << </asp:LinkButton>
</div>
</li>
Although, as others have said, you can also just apply the styles directly to li element. 虽然,正如其他人所说,您也可以直接将样式应用于li元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.