views:

79

answers:

4

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>
+2  A: 

Anchor tag

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

<a href="#">Read more</a>

You can embed an anchor tag inside a block element. So something like this

<p><a href="#">Back to top</a></p>
rahul
only <a> without <p> u mean
metal-gear-solid
Yes. just an <a>.
Daniel Vassallo
You can embed an anchor tag inside any block element.
rahul
but i need this in seperate line and <a> is inline
metal-gear-solid
You can use the CSS style: `display: block;`
Daniel Vassallo
`a.back { display:block;}` will fix that for you, if you give the `a` a class of 'back'.
Skilldrick
is it not against web standarss to change disply style any element through css while origionally has diffent display property in html specifiction?
metal-gear-solid
@Jitendra: No, it's not.
Skilldrick
+2  A: 

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.

Daniel Vassallo
but i've seen in many good site people use <a> inside <p>
metal-gear-solid
It's perfectly legal to use `<a>` inside `<p>`, and done all over the world. But using the `<p>` is only justified if you really want/need a paragraph-styled block. There's no reason to imprison free-standing, innocent text in `<p>` if it's not a para.
Carl Smotricz
A: 
Tatu Ulmanen
A: 
Carl Smotricz
u suggested <a> and <span> both are inline. so both will follow float direction of above element
metal-gear-solid
You can style an `a` like you can style a `span` - the extra tag is unnecessary.
Skilldrick
@Jitendra and Skilldrick: You both misunderstood my answer. It's not clear to me from the question that the "short texts" from the question are really meant to be links. The content of these texts hints they're links, but the OP isn't saying. If not, then `a` would not be appropriate.
Carl Smotricz
@carl yes these are links
metal-gear-solid
Thank you. My answer updated accordingly. But it's saying mostly what everybody else was saying already.
Carl Smotricz
@carl now see my first comment
metal-gear-solid
I'm sorry, but I cannot understand from your question what you want or what your problem (if any) is.
Carl Smotricz