views:

59

answers:

3
+2  Q: 

Html anchor tag

Hi All,

I was just wondering whether do I need to wrap a tag (a href="#") in a <p> tag? I guess it can be wrapped in any block level element like div but not sure.

Thanks

+4  A: 

It is an inline element and doesn't have to be wrapped anywhere.

The page body is already a block-level element, so anything you have inside it is respectively wrapped by it.

Developer Art
The body element is defined differently in different versions of HTML. In Strict it is defined as `<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->` and may not have `<a>` elements as children.
David Dorward
A: 
Tae
He didn't ask that. He asked if you need to wrap the anchor tag in a paragraph tag. Example <p><a href="http://example.com" title="Title Here">Link</a></p>
James Jeffery
A: 

No. If you want to make the anchor element block level you use the css property display: block;

<a href="http://www.google.com/mail" title="Google Web Mail" style="display: block;">Google Mail</a>

You can wrap an anchor in a p element if you want to do something like:

<p>My favorite search engine is <a href="http://www.google.com" title="Google Search Engine">Google</a>, because it allows me to fine tune my search</p>

James Jeffery