I was placing some icon fonts inside a link and then i asked myself:
is semantically correct to use a span
tag outside a p
one?
In example
<a href="http://fb.com">
<span class="my-icon-font">link</span>
</a>
From a semantic perspective, a span
really doesn't mean much. It's just a marker for some inline content.
From a technical perspective, a span
can go anywhere that you have an inline
display context, which basically means anywhere at all (since HTML allows you to have inline elements in the same context as block elements).
It certainly isn't limited to being inside a p
tag. It can go pretty much anywhere.
The short answer is NO
You can read these two section
span element
Contexts in which this element can be used: Where phrasing content is expected.
p element
Contexts in which this element can be used: Where flow content is expected.
Content model: Phrasing content.
A span
just allows phrasing content element inside it while a p
is an flow content element. However, a p
can contains a span
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With