HTML - attributes - size

revision:


Content

"size" attribute : defines the width and/or height of an element syntax some examples


"size" attribute : defines the width and/or height of an element

top

The size attribute defines the width of the <input> and the height of the <select> element. It specifies the visible width, in characters, of an <input> element and works with the following input types: "text", "search", "tel", "url", "email", and "password".

To specify the maximum number of characters allowed in the <input> element, use the "maxlength" attribute.


syntax

top

<input size="number">

number: specifies the width of an <input> element, in characters. Default value is 20.

<select size="number"></select>

number: the number as value indicates the number of rows visible.


some examples

top




codes:
                    <form style="margin-left:3vw;" action="/action_page.php">
                        <label for="fname">First name:</label>
                        <input type="text" id="fname" name="fname" size="50"><br><br>
                        <label for="pin">PIN:</label>
                        <input type="text" id="pin" name="pin" maxlength="4" size="4"><br><br>                         
                        <input type="submit" value="Submit">
                    </form>
                

codes:
                    <form style="margin-left:3vw;" name="user_info" action="action_get.php" method="get"> 
                        <label>Select your favourite sports</label> 
                        <select size="3">
                            <option value="Soccer">Soccer</option>
                            <option value="Hockey">Hockey</option>
                            <option value="Tennis">Tennis</option>
                            <option value="Golf">Golf</option>
                            <option value="Badminton">Badminton</option>
                            <option value="Cycling">Cycling</option>
                        </select><br/>
                        <input type="submit" name="submit" value="Submit" />