在HTML中拥有锚标签(< a>)的孩子是否合法? [英] Is it legal to have children of an anchor tag (<a>) in HTML?

查看:169
本文介绍了在HTML中拥有锚标签(< a>)的孩子是否合法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML中拥有锚标记的子项是否合法?举例来说:

 < a> 
< font>示例< / font>
< img src =example.jpg/>
< / a>

它在浏览器中正常工作,但它有效吗?请帮助 解决方案

是的 - 甚至更多的是随着HTML 5(来自规范)


尽管之前HTML版本将元素限制为只包含短语内容(基本上,以前的版本称为内联内容),现在a元素是透明的;也就是说,现在允许a元素的一个实例包含流内容(实质上,以前版本中称为块内容的内容) - 如果该元素的父元素是允许包含流内容的元素。


< blockquote>

Is it legal to have children of an anchor tag in HTML? For an example:

 <a>
     <font>Example</font>
     <img src="example.jpg"/>
 </a>

It works fine in the browsers.But is it valid? Please help

解决方案

Yes - even more so with the advent of HTML 5 (From the spec):

Although previous versions of HTML restricted the a element to only containing phrasing content (essentially, what was in previous versions referred to as "inline" content), the a element is now transparent; that is, an instance of the a element is now allowed to also contain flow content (essentially, what was in previous versions referred to as "block" content)—if the parent element of that instance of the a element is an element that is allowed to contain flow content.

这篇关于在HTML中拥有锚标签(&lt; a&gt;)的孩子是否合法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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