I am filling a textarea with content for the user to edit.
Is it possible to make it stretch to fit content with CSS (like overflow:show for a div)?
Here is a function that works with jQuery (for height only, not width):
function setHeight(jq_in){
jq_in.each(function(index, elem){
// This line will work with pure Javascript (taken from NicB's answer):
elem.style.height = elem.scrollHeight+'px';
});
}
setHeight($(''));
Note: The op asked for a solution that does not use Javascript, however this should be helpful to many people who come across this question.