一个在h2,或h2在一个 [英] a in h2, or h2 in a

查看:97
本文介绍了一个在h2,或h2在一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标题,我想链接到网站部分,在以下

上下文中:


< h1>网站内容< / h1>

< h2>第一部分< / h2>

< h2>第二部分< / h2>

< h2>第三部分< / h2>


我希望章节标题可以用于

网站的相关部分。因为我不是专家,请原谅我这是一个愚蠢的问题,但是

哪个更好(从很好的html开始):


< a href =" section1">< h2>第一部分< h2>< / a>


- 或 -


< ; h2>< a href =" section1">第一部分< / a>< / h2>?


至少我注意到一些(较旧的)浏览器倾向于如果

我会使用a:hover。


感谢你的时间,

suncho

I have a heading that I would like to link to site section, in the following
context:

<h1>Site Contents</h1>
<h2>First Section</h2>
<h2>Second Section</h2>
<h2>Third Section</h2>

I want that the section headings are poining to the relevant sections of the
site. Since I am not specialist, excuse me if it is a stupid question, but
which is better (in sence of good html):

<a href="section1"><h2>First Section<h2></a>

- or -

<h2><a href="section1">First Section</a></h2>?

At least I noticed that some (older) browsers tend to render it diferenly if
I use a:hover.

Thanks for your time,
suncho

推荐答案

Atanas Boev写道:
Atanas Boev wrote:
我希望章节标题能够到达网站的相关部分。因为我不是专家,请原谅我是否是一个愚蠢的问题,
但哪个更好(从优秀的html开始):

< a href =" section1"> < h2>第一部分< h2>< / a>
I want that the section headings are poining to the relevant sections of
the site. Since I am not specialist, excuse me if it is a stupid question,
but which is better (in sence of good html):

<a href="section1"><h2>First Section<h2></a>




这不是HTML,< a>元素是内联的,不能包含块元素

(< h *>元素是块)。

-

David Dorward< http://dorward.me.uk/>



This is not HTML, <a> elements are inline and cannot contain block elements
(<h*> elements are blocks).
--
David Dorward <http://dorward.me.uk/>


Atanas Boev写道:
Atanas Boev wrote:
我希望章节标题是关注
网站的相关部分。因为我不是专家,请原谅我这是一个愚蠢的问题,但是
哪个更好(从好的html开始):

< a href =" section1"> < h2>第一部分< h2>< / a>


内联*不能*包含块级别。

- 或 -

< h2>< a href =" section1">第一部分< / a>< / h2>?
I want that the section headings are poining to the relevant sections of the
site. Since I am not specialist, excuse me if it is a stupid question, but
which is better (in sence of good html):

<a href="section1"><h2>First Section<h2></a>
Inline *can''t* contain block-level.

- or -

<h2><a href="section1">First Section</a></h2>?




阻止*可以*包含内联级别。


而不是''section''使用''#section''或者是您指向的页面

称为''section''(没有扩展名),这将是使这个有效的URI。


另外,如果你要制作一个链接列表,你最好使用< ul>

而不是< h2>,< h2>可以用来指出:


< ul>

< li>< a href ="#section1"> First Section< ; / a>< / li>

< / ul>


<! - 更多文档 - >


< h2 id =" section1">第一部分< / h2>


-

Anne van Kesteren

< http://www.annevankesteren.nl/>



Block *can* contain inline-level.

Instead of ''section'' use ''#section'' or is the page you are pointing to
called ''section'' (without extension), which would make this a valid URI.

Also, if you are making a list of links, you are better of using <ul>
instead of <h2>, <h2> can be used to be pointed to:

<ul>
<li><a href="#section1">First Section</a></li>
</ul>

<!-- more document here -->

<h2 id="section1">First Section</h2>

--
Anne van Kesteren
<http://www.annevankesteren.nl/>


在文章< bt ******** **@news.cc.tut.fi>在

comp.infosystems。 www.authoring.html ,Atanas Boev写道:
In article <bt**********@news.cc.tut.fi> in
comp.infosystems.www.authoring.html, Atanas Boev wrote:

< a href =" section1">< h2>第一部分< h2>< / a>

- 或 -

< h2>< a href =" section1">第一部分< / a>< / h2>?

<a href="section1"><h2>First Section<h2></a>

- or -

<h2><a href="section1">First Section</a></h2>?




第一个是错的,第二个可能是正确的。


但是你真的希望标题是LINK吗?通常情况下,

标题可以与其他地方相关联。在这个

的情况下你需要

< h2>< a name =" section1"> First Section< / a>< / h2>


-

Stan Brown,Oak Road Systems,美国纽约州科特兰县
http://OakRoadSystems.com/

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

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

CSS 2规范:< a rel =nofollowhref =http://www.w3.org/TR/REC-CSS2/\"target =_ blank> http://www.w3.org/TR/REC-CSS2/

2.1更改: http:/ /www.w3.org/TR/CSS21/changes.html

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



The first is wrong, and the second may be correct.

But do you really want the heading to be a LINK? Normally the
headings are placed that can be linked to, from elsewhere. In this
case you would want
<h2><a name="section1">First Section</a></h2>

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/


这篇关于一个在h2,或h2在一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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