Is it possible to place <p> tag inside <a> tag? Also will W3C validator accept such attempt? If I'm correct, the p tag is block and a tag is inline, but I could change with CSS, couldn't I? And if I will do that, will validator see it or no?

  • just being a bit picky, but the tag is the start and end bits inside the brackets, what you are calling a tag is an element. :) Tony Crockford almost 9 years ago

2 answers

This was chosen as the best answer

Why would you want to?

If you want a whole paragraph to be a link, just wrap the text in the anchor element:

<p><a href="#">Some paragraph of text that should be a link</a></p>

The only valid content for an anchor element is any inline element, but not another anchor. Restyling a block level element with CSS won't make the HTML valid. You could make all the text clickable but only underline some of it, by using a span:

<p><a href="#">Some paragraph of text that should be a <span>link</span</a></p>


a{text-decoration: none;}
a span{text-decoration:underline}

If you're looking for a way to make block elements clickable, then there's a nice jQuery plug-in that will facilitate that:

Answered almost 9 years ago by Tony Crockford

Yep, you can as of HTML5. This let's you do nice things such as:

<a href="/whatever/">
    <img src="/someimage.jpg" />
    <p>Some text</p>

Making a nice big click target that includes lots of stuff in one go. This is nice as you can use the :focus and :active selectors to style it without JS as well. Good news is this works in every browser as well, even older ones.

Answered almost 9 years ago by Rich Bradshaw
  • Eugene also asked about validation. This will validate if the doctype is HTML5, not otherwise. Doug almost 9 years ago
  • with an HTML5 doctype, the a element may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as there is no interactive content within (e.g. buttons or other links). How that content will be rendered by current browsers may, however, be unexpected. Caveat Emptor :) Tony Crockford almost 9 years ago