用id替换名称 [英] Replacing name with id

查看:84
本文介绍了用id替换名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在在HTML 4.01中有一堆旧网页严格我每时都更新

,然后修改材料。当使用< a

name ="时,它们被写回来了。是包含锚的常规方法。大多数

内部锚点遵循非常标准的布局,并且与

和h3标题相关联。


我想知道是否有任何理由不改变这些< a

name ="锚点到< h3 id ="锚?我认为所有最近的浏览器

都可以在任何元素上使用id作为锚点。我也收集了这个名字

在我还没有使用的一个或另一个XHTML版本中被弃用

由于IE。我确实认为,如果我确定我已经厌倦了为IE提供服务,那么将来可能会更方便。对于XHTML,我可能会感到很尴尬。


我将对所有页面进行其他全局更改,因此此更改

只是为我的工作添加了另外几组全局替换。


-
http://www.ericlindsay.com

I have a bunch of old web pages now in HTML 4.01 Strict I update every
now and then with revised material. They were written back when using <a
name=" was the normal method of including an anchor. Most of the
internal anchors follow a very standard layout, and are associated with
an h3 heading.

I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors? I gather that all recent browsers
work fine with id on any element as an anchor. I also gather that name
is deprecated in one or another of the XHTML versions I am not yet using
due to IE. I did think it might be handy in future to be a little closer
to XHTML, if I do decide I am tired of catering to IE.

I would be making other global changes to all the pages, so this change
simply adds another few sets of global replacements to my work.

--
http://www.ericlindsay.com

推荐答案

Scripsit Eric Lindsay:
Scripsit Eric Lindsay:

我想知道是否有任何理由不改变这些< a

name ="锚点到< h3 id ="锚?
I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors?



不是真的,除非你正在做一些需要id属性的脚本

元素。

Not really, unless you''re doing some scripting that needs id attributes
for the elements.


我收集所有最近的浏览器

可以在任何元素上使用id作为锚点。
I gather that all recent browsers
work fine with id on any element as an anchor.



对。我们现在几乎可以忽略Netscape 4.

Right. We can virtually ignore Netscape 4 these days.


我也收集了这个名字

在一个或另一个XHTML版本中被弃用
I also gather that name
is deprecated in one or another of the XHTML versions



那是无关紧要的。 (从技术上讲,它已被弃用于< aelements,但

并非所有元素都被弃用。如你所知,弃用的原因是

id属性为了这个目的,它更像逻辑和XML。)

That''s irrelevant. (Technically, it''s deprecated for <aelements, but
not for all elements. The reason for the deprecation, as you know, is
that the id attribute is more logical and XML-like for the purpose.)


我确实认为将来可能会很方便成为一个更接近的b
更接近到XHTML,如果我确定我厌倦了迎合IE。
I did think it might be handy in future to be a
little closer to XHTML, if I do decide I am tired of catering to IE.



没关系。如果您曾经转换为XHTML,那么无论如何都要进行几次

的更改,并且_this_更改并不是特别的。您可以将id用于新页面,就像您可能使用

仅小写元素名称一样,因为这些在经典HTML

以及XHTML中是必需的。但是更改现有的< a name = ...>

锚点或元素名称中现有的大写字母使用是没有意义的。

_Any_更改,无论多么自动化,涉及错误的风险;一些

假设可能会失败,而你的正则表达式(或其他)可能会以某种特殊情况错过一些特殊情况并产生混乱。只有在有某些东西要赢的时候才能获得

风险,比如出于某种原因而执行转换为XHTML的

(完全)。 />

-

Jukka K. Korpela(Yucca)
http://www.cs.tut.fi/~jkorpela/

It doesn''t matter. If you ever switch to XHTML, you will have several
changes to be made anyway, and making _this_ change is not really
special. You might use id for new pages, just as you might use
lowercase-only element names, because these are allowed in classic HTML
as well as required in XHTML. But changing existing <a name= ...>
anchors or existing use of uppercase in element names is just pointless.
_Any_ change, no matter how automated, involves a risk of errors; some
assumptions may just fail, and your regular expression (or whatever) may
somehow miss some special case and produce a mess. It''s better to take
risks only when there is something to be won, i.e. when performing the
(full) conversion to XHTML for some real reason.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Sun,2008年1月6日14:45:14来自Eric Lindsay的+1000

< NO ************* @ ericlindsay.com>:
Sun, 06 Jan 2008 14:45:14 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:

我现在在HTML 4.01中有一堆旧网页严格我每次更新每个
,然后使用修改后的材料。当使用< a

name ="时,它们被写回来了。是包含锚的常规方法。大多数

内部锚点遵循非常标准的布局,并且与

和h3标题相关联。


我想知道是否有任何理由不改变这些< a

name ="锚点到< h3 id ="锚?
I have a bunch of old web pages now in HTML 4.01 Strict I update every
now and then with revised material. They were written back when using <a
name=" was the normal method of including an anchor. Most of the
internal anchors follow a very standard layout, and are associated with
an h3 heading.

I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors?



我想不出任何。 IIRC,Netscape的一个非常古老的版本兑现了

name =但不是= id,但现在已经有好几年了。只需要在你的脚本中小心地删除相关的< / a>,即使它不是在同一行上,也不是



-

Stan Brown,Oak Road Systems,美国纽约汤普金斯县
http://OakRoadSystems.com/

HTML 4.01规范: http://www.w3.org/TR/html401/

验证器: http://validator.w3.org/

CSS 2.1规范: http://www.w3.org/TR/CSS21/

验证者: http://jigsaw.w3.org/css-validator/

为什么我们不能帮助你:
http://diveintomark.org/archives/200..._wont_help_you

I can''t think of any. IIRC, a very old version of Netscape honored
name= but not =id, but that''s been quite a few years now. Just be
careful in your script to remove the associated </a>, even if it''s
not on the same line.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won''t Help You:
http://diveintomark.org/archives/200..._wont_help_you


Scripsit Jukka K. Korpela:
Scripsit Jukka K. Korpela:

Scripsit Eric Lindsay:
Scripsit Eric Lindsay:

>我想知道是否有任何理由不改变这些< a
名称= QUOT;锚点到< h3 id ="锚?
>I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors?



不是真的,除非你正在做一些需要id的元文件
元素的b $ b属性。


Not really, unless you''re doing some scripting that needs id
attributes for the elements.



糟糕,我似乎误读了这个问题。我回答了问题在

有任何理由......。


-

Jukka K. Korpela (Yucca)
http://www.cs。 tut.fi/~jkorpela/

Oops, I seem to have misread the question. I answered the question "in
there any reason...".

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


这篇关于用id替换名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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