在<a> attribute

时间:2017-04-04 16:22:17

标签: html html5

I am wandering what the general rule of doing the above is, my editor still gives me a warning saying that the div is in an invalid location. Most questions regarding this are pushing on for 6 years old. Is it still bad to wrap a div element with an <a> attribute? for example, is the following code an acceptable thing to do now or should it be avoided?

<a href="/somelink.html">
  <div class="fancyBox">
    <p> some content </p>
  </div>
</a>

1 个答案:

答案 0 :(得分:1)

你的编辑已经过时了。

从HTML 5开始(2014年10月28日作为W3C推荐发布),<div>元素被允许作为<a>元素的子元素。

HTML 4中的情况并非如此。