我有以下的Struts2代码,它生成了一个承运人列表。只有在用户选择了装运类型后才会显示出来(JavaScript会移除
hidden
类)。<div class ="showIfNotOther hidden">
<div class="row">
<div class="col-xs-12 rowsecthead" id="shipperInfoHeader"><s:text name="shipperInfo"/></div>
</div>
<s:iterator value="chosenShipperViewList" status="status">
<div class="row small-line-height">
<div class="col-sm-2 col-xs-12 "><label for='<s:property value="%{'deleteShipper'+#status.index}" />' class="pull-right"><s:text name="deleteShipperInfo"></s:text>:</label></div>
<div class="col-sm-3 col-xs-12 text-left">
<s:url var="deleteLink" action="shipment_deleteShipperFromChosenShipperViewList"></s:url>
<s:a id="%{'deleteShipper'+#status.index}" href="%{deleteLink}"> <img src="/llr/theme/delete.gif" width="16" height="16" alt="Map Red X" ></s:a>
</div>
<hr>
</div>
</s:iterator>
Struts2代码生成以下HTML,每个“删除托运人信息:”标签都与每个<a>
元素相关联,通过一个ID(deleteShipper0
,deleteShipper1
等)进行标识,这是我理解的508兼容性所必需的。<div class ="showIfNotOther hidden">
<div class="row">
<div class="col-xs-12 rowsecthead" id="shipperInfoHeader">Shipper Information</div>
</div>
<div class="row small-line-height">
<div class="col-sm-2 col-xs-12 "><label for='deleteShipper0' class="pull-right">Delete Shipper Info:</label></div>
<div class="col-sm-3 col-xs-12 text-left">
<a id="deleteShipper0" href="/llr/shipment_deleteShipperFromChosenShipperViewList.action?organizationName=Mercy"><img src="/llr/theme/delete.gif" width="16" height="16" alt="Map Red X" ></a>
</div>
<hr>
</div>
<div class="row small-line-height">
<div class="col-sm-2 col-xs-12 "><label for='deleteShipper1' class="pull-right">Delete Shipper Info:</label></div>
<div class="col-sm-3 col-xs-12 text-left">
<a id="deleteShipper1" href="/llr/shipment_deleteShipperFromChosenShipperViewList.action?organizationName=Nuclear"><img src="/llr/theme/delete.gif" width="16" height="16" alt="Map Red X" ></a>
</div>
<hr>
</div>
当我将HTML放入 W3C标记验证服务中时,出现错误。
HTML确实不符合规范吗(如果不符合规范,该如何修复),还是这只是W3C标记验证服务中的错误?标签元素的“for”属性必须引用非隐藏表单控件。