JSFiddle - React, Tailwind, and code Playground
by Ryan Britton
HTML
<div>
<span>adslafk jdasjf kls fjsldajk <br/> fasdjk fjl;jkl fjklj kljkj<br/> fasdjk fjl;jkl fjklj kljkj<br/> fasdjk fjl;jkl fjklj kljkj<br/> fkl fjkljka djk </span>
<textarea></textarea>
</div>
CSS
div {
height: 20em;
background-color: gray;
}
textarea {
display: block;
border:none;
}
span {
padding:1em;
display: inline-block;
}
JavaScript
document.getElementsByTagName('textarea')[0].style.height = (document.querySelector('div').offsetHeight-document.querySelector('span').offsetHeight-4)+'px'
alert((document.querySelector('div').offsetHeight-document.querySelector('span').offsetHeight)+'px')
alert(document.querySelector('div').offsetHeight)