公告
财富商城
积分规则
提问
发文
2019-01-21 06:00发布
在下西门庆
I want to nest span and a tags. Should I
span
a
<span>
<a>
Semantically I think makes more sense as is a container for a single element and if you need to nest them then that suggests more than element will be inside of the outer one.
3 - It doesn't matter.
BUT, I tend to only use a <span> inside an <a> if it's only for a part of the contents of the tag i.e.
<a href="#">some <span class="red">text</span></a>
Rather than:
<a href="#"><span class="red">some text</span></a>
Which should obviously just be:
<a href="#" class="red">some text</a>
that depends on what you want to markup.
It can matter if for instance you are using some sort icon font. I had this just now with:
<span class="fa fa-print fa-3x"><a href="some_link"></a></span>
Normally I would put the span inside the A but the styling wasn't taking effect until swapped it round.
最多设置5个标签!
Semantically I think makes more sense as is a container for a single element and if you need to nest them then that suggests more than element will be inside of the outer one.
3 - It doesn't matter.
BUT, I tend to only use a
<span>
inside an<a>
if it's only for a part of the contents of the tag i.e.Rather than:
Which should obviously just be:
that depends on what you want to markup.
<a>
inside<span>
.<span>
into<a>
It can matter if for instance you are using some sort icon font. I had this just now with:
Normally I would put the span inside the A but the styling wasn't taking effect until swapped it round.