'Should I use a .class or element in HTML? [closed]
Currently, I use <emb> to stylize text, but should I turn emb into a class using a dot? I was checking <span> element where a class can be used so I wondered if I should try or, leave it. Would there be any benefit?
HTML:
This is some text
<emb>This is some styled text</emb>
CSS:
<style>
emb {
font-weight: 500;
background: transparent;
font-size: 18px
}
</style>
I often use <emb> as needed to highlight parts of text.
Solution 1:[1]
emb is not an existing, valid HTML tag and you should not be using it in 'pure' HTML/CSS systems.
There are several HTML tags that enable you to emphasise or mark text of special relevance.
They each have slightly different meanings/uses and you need to look up the meaning of each to make sure you are using them correctly (such tags include em, i, strong, mark).
However, they are not intended for general purpose styling for which you should use an 'ordinary' CSS class in an element with a tag which otherwise has no great semantic inference of its own (such as span as you mention).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | connexo |
