w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to limit width of

-

tag by length of content

Seems like you are trying to reproduce a <fieldset> element. So why not use that element?

<form>
    <fieldset>
        <legend>Wählen sie das anzuzeigende Model</legend>
        <select id="selectModelDDL" onchange="createTable(this);">
            <option value="1">1</option>
        </select>
    </fieldset>
</form>

With the <fieldset> you will create the border around the elements where the <legend> is the text that is on the border.
Now you can just align the text to the center:

fieldset
{
    text-align: center;
    border: 1px solid black;
    border-radius: 15px;
    font-weight: bold;
    font-size: 13px;
    padding: 10px;
}

jsFiddle





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.