I'm currently facing an issue where I have multiple divs all sharing the same "Text" class. These divs don't have set width or height values, and are adjusting based on the content inside them, which varies in width. The problem arises when other divs with the same class inherit the width of the div containing the most text. Is there a way to automatically resize each div's width to fit its specific text using CSS or JavaScript without manually setting widths for each div?
CSS
.Text{
background-color: teal;
padding: 7px;
margin: auto;
}
HTML
<div class="Text">
<h1>This is Some Text</h1>
</div>
<br />
<div class="Text">
<h1>This is More Text only longer than the first</h1>
</div>