Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a <p> tag in <a> tag? [duplicate]

Tags:

html

css

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>
like image 852
jiguang Avatar asked Nov 28 '22 11:11

jiguang


1 Answers

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.

like image 194
Quentin Avatar answered Dec 09 '22 17:12

Quentin