How to make text bold in JavaScript?

To make text bold in JavaScript, do this: element.style.fontWeight = 'bold'.

For example, if this is your element:

<div id="my-element">text</div>

Then you can make the text inside this element bold like so:

document.getElementById('my-element').style.fontWeight = 'bold';

And you can do the same with the style attribute in HTML:

<div id="my-element" style="font-weight: bold">text</div>