Question about changing text in elements with jQuery

Question about changing text in elements with jQuery
0

#1

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


#2

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


#3

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


#4

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


#5

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.


#6

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?


#7

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


#8

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.


#9

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.


#10

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.