Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html: What is the correct order of <a> and <p> tags?

Tags:

html

anchor

Which of the following, if either, is correct by standards?

<!-- Do the links surround the target link object --> <a href=''><p>Link Description</p></a> <!-- or does the object type encapsulate the link--> <p><a href=''>Link Description</a></p> 

I know they function the same, But it's a best practice/standards question. This could apply to ul/ol too.

The only reason I think to favor the <a> tag inside is with a situation like:

<p>This is a longer sentence with a <a href=''>short link here</a></p>

Thanks!

like image 736
j_syk Avatar asked May 23 '11 19:05

j_syk


People also ask

What is the correct HTML order?

Within a web page, some HTML tags are required for the page to be displayed correctly. These tags are <html> , <head> , <title> and <body> . The <html> tags must begin and end the document and the <head> tags must appear before the <body> tags. Also, the <title> tags must be within the <head> tags.

What is the HTML tag for P?

Definition and Usage. The <p> tag defines a paragraph. Browsers automatically add a single blank line before and after each <p> element. Tip: Use CSS to style paragraphs.

Is there p1 p2 in HTML?

<p1> <p2> etc. tags don't really exist. There is only <p> tags. When you add numbers, you are creating your own custom tags and styling those need to be done differently if you want them to behave like a standard <p> tag.

In which part of the HTML you add the P tag?

The <p> HTML element represents a paragraph. Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields.


2 Answers

The first example is only allowed in HTML5.

The second example is allowed in all versions of HTML/XHMTL.

like image 89
edeverett Avatar answered Oct 05 '22 16:10

edeverett


You can't wrap a block element with an inline element. You have to do this in that way:

<p><a href=''>Link Description</a></p>

This is W3C standard. Check this!

like image 39
ChristianB Avatar answered Oct 05 '22 15:10

ChristianB