可以< p>标记在< a>标签? [英] Can a <p> tag in <a> tag?

查看:127
本文介绍了可以< p>标记在< a>标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

当我们写某种产品列表时,您只需要一个链接,但它应该包含产品图片,产品名称,产品标题等,我们可以使用包含p或其他标签吗?有没有跨浏览器的问题?



我听说过html5,一个标签可以包含p标签,但仍然没有信心使用它。



一些代码如下:

 < ul class =xxx_list> 
< li class =hproduct>
< a href =#class =urltitle =target =_ blank>
< img class =photosrc =shoujike.jpgalt =手机壳>
< p>
< span class =price_wrap>& yen;< span class =price> 88.00< / span< / span>
< span class =fav>收藏< / span>
< / p>
< p>< a class =fnhref =>基本商品单元的商品名称< / a>< / p&
< / a>
< / li>
< / ul>


解决方案

在HTML 4.x元素不能包含< p> 元素。

元素不能包含 < a&

在HTML 5 - < a> 元素可能包含< p> 元素,但浏览器有点薄,你可能会发现你必须显式设置< a> 到 display: / code>。



问题中的代码还包括< a> < p> 中。这是不允许的。 < a> 元素可能不是另一个< a> 元素的后代。


Possible Duplicate:
Is putting a div inside an anchor ever correct?

When we write some kind of 'product list', you need only one link, but it should contain product image, product name, product title etc. can we use a contain p or some other tag? is there any cross browser issue?

I heard in html5, a tag can contain p tag, but still with no confidence about using it.

some code like so:

<ul class="xxx_list">  
<li class="hproduct">  
    <a href="#" class="url" title="" target="_blank">  
        <img class="photo" src="shoujike.jpg" alt="手机壳">  
        <p>  
            <span class="price_wrap">&yen;<span class="price">88.00</span</span>  
            <span class="fav">收藏</span>  
        </p>  
        <p><a class="fn" href="">基本商品单元的商品名称</a></p>  
    </a>  
</li>  
</ul>

解决方案

In HTML 4.x (and earlier) and XHTML 1.x — No. <a> elements may not contain <p> elements.

In HTML 5 — <a> elements may contain <p> elements, but browsers are a bit flaky about it and you may find you have to explicitly set the <a> to display: block in your stylesheet.

The code in the question also includes an <a> inside that <p>. This is not allowed. An <a> element may not be a descendant of another <a> element.

这篇关于可以&lt; p&gt;标记在&lt; a&gt;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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