The div or span elements as buttons?

0 like 0 dislike
5 views
Good evening. When you view the code of other sites I often notice that as the buttons are div and span.
The question arose why it is done and what is worse, the same button or a? There are some advantages of this method?
by | 5 views

3 Answers

0 like 0 dislike
Do it if:
1. Don't know what is better to use a button or a
2. Don't know/too lazy to remove the background, borders, and other delights from the button
3. A don't know/too lazy to remove the default action using preventDefault (clicking throws on the top of the page, trying to link to)
4. More options... =)
by
0 like 0 dislike
Generally better to use the button - it is better from the point of view of accessibility of the page. Different screen readers for the visually impaired rely on layout when reading. Well, anyway, if there is in the BOM button and link, then you need to use them as intended. Use div instead of a button in some cases when you do not want or are not able to deal with the junk in the specific case features of the rendering of the button element.
by
0 like 0 dislike
You can do for grouping and for strings use only div and span
That is to do a minimum of tags.
And to indicate the semantics (roles) to use WAI-ARIA
see here
by

Related questions

0 like 0 dislike
5 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,570 users