简体   繁体   English

div标签外面的href标签?

[英]a href tags on the outside of div tags?

I understand that div tags are containers for most tags, such as a href tags... with that said I have a document that works and only functions when the a href tag is around two div tags. 我知道div标签是大多数标签(例如href标签)的容器...表示我有一个文档,该文档仅在href标签位于两个div标签周围时才起作用。

If I adjust the div and a href so that it is w3c compliant, it distorts the website. 如果我调整div和href使其符合w3c,则会扭曲网站。 I could possibly adjust my .js and .css to make it work, but I would like to find an alternate solution. 我可以调整.js和.css使其起作用,但我想找到一个替代解决方案。 Can I keep the a href tag where it is now? 我可以将href标签保留在现在的位置吗?

Thanks for any help or suggestions. 感谢您的帮助或建议。

Link Here: http://momentum.freeiz.com/ 链接在这里: http : //momentum.freeiz.com/

Code Here: 此处代码:

<a href="hapo.htm" >        
  <div class="boxgrid_slideright">
    <div id="slideshow">
      <img class= "cover" src="images/home/ hapo/0.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/1.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/2.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/3.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/4.jpg" width="161" height="107" alt="hapo credit union"/>
    </div><!--slideshow--> 
  </div><!--boxgrid-->
</a>

You should style inline elements to behave as block element with css: 您应该设置内联元素的样式,使其与CSS一起充当块元素:

CSS: CSS:

a.whatever, .boxgrid_slideright, .slideshow {
  display: block;
}

HTML: HTML:

<a class="whatever" href="hapo.htm" >        
  <span class="boxgrid_slideright">
    <span id="slideshow">
      <img class= "cover" src="images/home/ hapo/0.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/1.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/2.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/3.jpg" width="161" height="107" alt="hapo credit union"/>
      <img class= "cover" src="images/home/ hapo/4.jpg" width="161" height="107" alt="hapo credit union"/>
    </span><!--slideshow--> 
  </span><!--boxgrid-->
</a>

XHTML 2 was going to allow use of the “href” attribute on any element, allowing for block level anchors and eliminating repetition of the same anchor in some cases or unnecessary additional tags in others. XHTML 2将允许在任何元素上使用“ href”属性,从而允许使用块级锚,并在某些情况下避免重复使用同一锚,而在其他情况下则避免了不必要的附加标记。 This really made sense, since the “a” tag is just a span, but the only span with an added ability of linking to somewhere else. 这确实是有道理的,因为“ a”标签只是一个跨度,而是唯一具有附加功能的跨度。 There is really no special semantic meaning to the “a”, and all links on a page could be found in parsing by finding tags with the “href”. “ a”确实没有特殊的语义含义,并且可以通过使用“ href”查找标签来解析页面中的所有链接。 In the early days of the development of HTML 5, the “href anywhere” approach was discussed, and I was excited thinking it was going to be part of HTML 5. At the time, that was the most interesting thing about HTML 5 to me. 在HTML 5的开发初期,人们讨论了“随处可见”的方法,我很高兴地认为它将成为HTML 5的一部分。当时,这对我来说是关于HTML 5的最有趣的事情。 。 But “href anywhere” would mean all previous browsers would not be able to see links at all (besides for the ones put in “a” tags for some reason), so the idea was scrapped. 但是“在任何地方都有href”将意味着所有以前的浏览器将根本看不到链接(出于某种原因,除了放在“ a”标记中的链接之外),因此该想法被废弃了。 Instead, the HTML 5 creators took advantage of an against-spec ability that current browsers already had: block level anchors. 取而代之的是,HTML 5创建者利用了当前浏览器已经具备的反规范功能:块级锚。 Browsers at least back to IE 6 will happily make “flow content” placed in an “a” tag into a link. 至少回到IE 6的浏览器将很乐意将放置在“ a”标记中的“流内容”制作为链接。 via - Toby Mackenzie 通过 -Toby Mackenzie

http://davidwalsh.name/html5-elements-links http://davidwalsh.name/html5-elements-links

http://html5doctor.com/block-level-links-in-html-5/ http://html5doctor.com/block-level-links-in-html-5/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM