0
A paragraph with the text, 'I am a Nigerian. Lucky me.' I'm trying to select the words, 'Lucky me' to format them. Need help😭
2 ответов
+ 4
use the <span> tag arround selected text.
Learn more here ( https://www.w3schools.com/tags/tag_span.asp )
+ 1
How are you doing so? You will eventually need to wrap a element around the text you wish to format , or try some other method !
a better way instead of wrapping the span or other element around word is to use range object that sets a starting and ending range that you provide for a particular element text and then surround that range with an element using surroundContent method.
Although using this method you are still wrapping an element around text but now you just need to set the new range offset positions for a particular element text instead of editing your html and placing an element to new position
https://code.sololearn.com/W34wFZpUI3QU/?ref=app