Solution 1 :

The problem is that you have given {display: block} property to your newly created HTML Element (Label) which will always take full width. Remove that, and by default <label> is an inline element so you won’t have any issues.

label{background: red;}
<label>Hello...Good Morning ...</label>

Problem :

i want to make label width fit label text width.when i change label text,label width must change.And when created label,label width must be fit label text

  var newP = document.createElement("label"); = 'color:' + $("#renk").val() + ';white-space:pre-wrap;display:block;overflow:auto;font-size:' + $("#font").val()+'px';