when someone has selected text and press the bold button the selected text will be bold and not all the textarea characters.
document.getElementById("bold").onclick = function() {
document.getElementById("textarea").style.fontWeight = "800";
}
<textarea id="textarea"></textarea>
<button id="bold">Make bold</button>
You can't style text inside of a textarea more then in your example.
But you can try this attempt with editable div: https://stackoverflow.com/a/50287002/4230037