Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Attributes

0/1

HTML Paragraphs

0/1

HTML Formatting

0/1

HTML Comments

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML Symbols

0/1
Text lesson

The size Attribute

The size attribute of the input specifies the visible width of the input field in terms of characters.

By default, the size is set to 20 characters.

Example

Define the width of an input field:

<form>
  <label for=”fname”>First name:</label><br>
  <input type=”text” id=”fname” name=”fname” size=”50″><br>
  <label for=”pin”>PIN:</label><br>
  <input type=”text” id=”pin” name=”pin” size=”4″>
</form>

The maxlength Attribute

The input maxlength attribute sets the maximum character limit allowed in an input field.

Please note: When maxlength is defined, the input field restricts the entry to the specified character count. However, it doesn’t offer any visual feedback. Therefore, if you wish to notify the user, you’ll need to implement JavaScript code.

Example

Establish a maximum character limit for an input field:

<form>
  <label for=”fname”>First name:</label><br>
  <input type=”text” id=”fname” name=”fname” size=”50″><br>
  <label for=”pin”>PIN:</label><br>
  <input type=”text” id=”pin” name=”pin” maxlength=”4″ size=”4″>
</form>