是否认为< a>的'name'属性过时了?锚标签? [英] Is the 'name' attribute considered outdated for <a> anchor tags?

查看:155
本文介绍了是否认为< a>的'name'属性过时了?锚标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio不喜欢页面定位标记:
$ b


验证(XHTML 1.0 Transitional):
属性'名称'被认为是过时的
。推荐使用


我使用 name 属性以这种方式< / p>

 <?xml version =1.0encoding =UTF-8?> 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.1 // ENhttp://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
< html xmlns =http://www.w3.org/1999/xhtmlxmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi:schemalocation = http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsdxml:lang =en>
...
< body>
...
< p>在此页& hellip;< / p>
< ul>
< li>< a href =#one>第一部分< / a>< / li>
...
< / ul>
...
< h2>< a name =one>第一部分< / a>< / h2>
...
< / body>
< / html>

真的有更现代的做法吗?或者Visual Studio充满垃圾?

解决方案

您应该使用 id 属性。以同样的方式工作,您不需要人工< a name = ...> ,但只需
$ b $第一部分< / h2>


Visual Studio doesn't like on-page anchor tags:

Validation (XHTML 1.0 Transitional): Attribute 'name' is considered outdated. A newer construct is recommended.

I'm using name attributes in this way…

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" xml:lang="en">
    ...
    <body>
        ...
        <p>On this page&hellip;</p>
        <ul>
            <li><a href="#one">Section One</a></li>
            ...
        </ul>
        ...
        <h2><a name="one">Section One</a></h2>
        ...
    </body>
</html>

Is there really a more-modern way of doing this? Or is Visual Studio full of crap?

解决方案

You should use the id attribute instead. Works the same way, and you don't need an artifical <a name=...>, but simply

<h2 id="one">Section One</h2>

这篇关于是否认为&lt; a&gt;的'name'属性过时了?锚标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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