Is adding a css class to a <b> tag valid html/css
Yes, b tag can have all global attributes, including class
.
The full list of attributes, you can add to b
element:
- accesskey
- class
- contenteditable
- contextmenu
- dir
- draggable
- dropzone
- hidden
- id
- inert
- itemid
- itemprop
- itemref
- itemscope
- itemtype
- lang
- spellcheck
- style
- tabindex
- title
- translate
You can also use any custom data attributes.
Finally, you can add also ARIA role
attribute.
Of course. There's nothing wrong with that.
However, it's generally a bad idea to use class
purely for identifying an element. Consider using something like data-reference
or something, as this will be more correct (and more efficient on the browser not having to keep track of a class that's not used as a class)
Yes, this is perfectly valid. Absolutely nothing wrong with it.