因此,快速背景是我有一个列出一组结果的页面,每个页面都显示一个缩略图(图像标签),简短描述(段落标签)和标题(标签标签)。 结果项目链接到它的小册子。
我希望每个结果(大约100px的高度和全部宽度)成为单个链接,而不是让图像和标题成为单独的链接。 这是出于设计原因和SEO(对于给定结果有1个链接而不是2个,帮助控制内部链接以及给定页面上链接的数量等)
问题是html4和xhtml不允许在链接中嵌套标题或段落。
我已经通过使用标题和p的跨度来管理这一点,但是这次我需要结果项中的标题。
我想知道的是,如果任何人有办法解决这个问题,如果不是在这种情况下不符合标准的问题是什么?
谢谢丹尼斯
编辑:Aplogies如果这不明确,希望它现在。
So the quick background is that I have a page listing a set of results and for each I display a thumbnail (image tag), short description (paragraph tag) and title (header tag). The result item links to it's brochure.
I want each result (about 100px in height and full width) to be a single link rather than have the image and title being seperate links. This is for both design reasons and SEO (to have 1 link rather than two for a given result with help control internal linking and the number of links on the given page etc.)
The issue is that html4 and xhtml don't allow nesting of headers or paragraphs in links.
I have managed this before by using spans for the header and p but this time I need the header in the result item.
What I'd like to know is if anyone has a way around this and if not what are the issues with not meeting the standards in this scenario?
Thanks Denis
Edit: Aplogies if this wasn't clear, hopefully it is now.
最满意答案
短:不。
链接是内联元素(它们像词汇一样流动,不像块元素那样得到自己的行)。 HTML标准说:内联元素不能包含块元素。
这是有道理的。 想想这个例子:word1 BLOCK word2。 浏览器应该如何布置BLOCK? 当它遇到元素时,它试图将文字包装成尽可能小的垂直空间。 它是否应该跳出单词换行并稍后返回? 或者把BLOCK当作一个单词(打破块默认为100%宽度的合约)?
也就是说,大多数浏览器仍然会正确显示。 但你不能依赖它。
Short: No.
Links are inline elements (they flow like words unlike block elements which get their own line). The HTML standard says: Inline elements can't contain block elements.
This makes sense. Think of this example: word1 BLOCK word2. How should the browser layout the BLOCK? When it encounters the element, it's trying to wrap words into as little vertical space as possible. Should it break out of the word wrap and then return later? Or treat BLOCK as a word (breaking the contract that block elements get 100% width by default)?
That said, most browser will still display this more or less correctly. But you can't depend on it.
更多推荐
发布评论