Search code examples
xhtmlsemanticsweb-standardssemantic-markup

What tag should be used for short text like "back to top" , "Read more" etc?


What tag should be used for short text like.

Back to top

Read more

is <p> appropirate or something else should be use. because these are not paragraph.

Which is more semantic

<p><a href="#mainWrapper">Back to top</a></p>

or

<a href="#mainWrapper">Back to top</a>

or

<div><a href="#mainWrapper">Back to top</a></div>

Solution

  • In general you should use the anchor <a> tag.

    Nesting an <a> inside a <p> is perfectly valid, but in general the <p> should be reserved for paragraphs of text. Since yours is just a link, the <a> tag alone will probably be the most recommended.

    If you want your link to appear as a block element, simply style it with display: block;. The fact that the <a> tag is normally displayed inline is only because it is its default style.