'Scale border width depending on text length

im learning css and not very good at it at the moment. Is there a way to scale the border width depending on the text width as a user could input a short name or a long one. This is the CSS of the border. Thanks for any help in advance.

#summonerInfo{
  border:2px solid black;
  margin-left: 25%;
  width: 50%;
}

enter image description here

edit: just set width:auto;

css


Solution 1:[1]

set width to auto; width:auto; it will try to keep the contents inside the allocated box.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 willscode