How to Increase the Size of an HTML Drop-Down Box

104 7
    • 1). Create a new HTML page in a text editor or Web design application. Add the code below between the HTML "<body>" "</body>" tags to add a HTML form and drop-down menu to the page.

      <form name="form1" method="post" action="example.htm">

      <select name="exampleSelect">

      <option value="1">Option One</option>

      <option value="2">Option Two</option>

      <option value="3">Option Three</option>

      </select>

      </form>

      Save the page as "example.htm" and upload to your Web server. View the page in a Web browser, and you will see the drop-down menu is automatically resized to fit the longest option, which is "Option Three."

    • 2). Add the following code to create a new CSS stylesheet, just above the closing HTML "</head>" tag.

      <style type="text/css">

      .wide-dropdown {

      width: 200px;

      }

      </style>

      This creates a new style class named "wide-dropdown," which sets the width of the element to which it is assigned to 200 pixels.

    • 3). Assign the new style class to the drop-down menu by changing the HTML select tag to read:

      <select name="exampleSelect">

      Upload the page to your Web server, and then refresh the page in your Web browser. You will see that the drop-down has a width of 200 pixels.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.