0

Can I use more then one span in a link?

Like this:

<a href="#" class="sprite">
  <span class="iconSpan"></span>
  <span class="textSpan">text</span>
</a>
Adrift
  • 58,167
  • 12
  • 92
  • 90
WIWIWWIISpitFire
  • 1,539
  • 1
  • 12
  • 20

5 Answers5

4

<span> is inline element so you can have any no of required span elements inside another html element.

web2008
  • 914
  • 4
  • 11
1

SPAN is a GENERIC inline container. It does not matter whether an a is inside span or span is inside a as both are inline elements. Feel free to do whatever seems logically correct to you.

try this

http://jsfiddle.net/nVNqU/

<a href="#" class="sprite iconSpan textSpan">
  text
</a>
Falguni Panchal
  • 8,873
  • 3
  • 27
  • 33
0

Yes you can have as many as you need :) a attribute is like a div, it covers everything inside it :)

Gintas K
  • 1,438
  • 3
  • 18
  • 38
0

Both forms are legal. (<a> inside <span> or <span> inside <a/>):

https://stackoverflow.com/a/7427244/2523764

Community
  • 1
  • 1
Arbaoui Mehdi
  • 754
  • 6
  • 18
0

Yes you can have as many span as you will need.

Michael Unterthurner
  • 921
  • 1
  • 10
  • 25