Question about changing text in elements with jQuery

Im wondering what do em tags ( and < /em) stand for? And do they just alter/change the way text looks?

Yes. em for “emphasis”, makes it look italics.

1 Like

It also can be used so screen readers emphasize or speak strongly the words between the tags

1 Like

Does emhpasis only make it italic? Do we use other stuff simmilar to emphasis to change text to different looks or what?

You can technically style and italicize any text you want with css:

h1.span {
    font-style: italic;
    font-weight: 500;
    color: blue;

Spans and divs can be used to add emphasis, not just em tags.

Visually speaking, em and the “i” tag both make the text look italics on screen.

MDN has a nice explanation for difference between em and “i”.

Another related example is “strong” and “b” for making the text look bold.

But as Isaac said, you can pretty much change the text style of any html element using CSS properties. But “em” and "strong"s default look is italic and bold respectively.

Makes sense?

i tag also means icon right? Do we use i for italics only in jQuery or we can use them in CSS too?

Not officially, but it is often used like that. If you are using font-awesome for example, they have it in an i just for semantics and consistency, but you could also use a span or even an em for icons as it is just a certain font that has icons.

Not sure what you mean. i is HTML, so you can control it with jQuery and CSS like any other element. You can use it for icons, or italics, or even paragraphs if you for some reason wanted to. Just be consistent.

1 Like

Well im a beginner in jQuery so im very curious if i im not sure what something means and is used for. Like this i learn more too. Thanks for help.

However, worth pointing out, this should not be confused with the ‘em’ CSS property which lists as following:

em Relative to the font-size of the element (2em means 2 times the size of the current font)

i.e. font-size: 2em;

Or when you see this in CSS it is not making your fonts italic, which I think is what you are asking. It instead sizes the font relatively.