The difference between Input's size and maxlength attributes

The difference between Input's size and maxlength attributes
I recently used the input size and maxlength attributes in a project. In the past, I just used them without paying attention to the difference between these two tags. I searched on Baidu today and got some understanding. Specially recorded here!

Copy code
The code is as follows:

<p>Name: <input type="text" name="fullname" maxlength="5" /></p>
<p>Name2: <input type="text" name="fullname" size="5" /></p>

maxlength="5", then only 5 characters can be entered in the input box<br/>
size="5" means that the input box only displays 5 visible characters, but you can enter 'infinite' characters

That is, the size attribute specifies the width of the input field (here, the Name2 text box only displays 5 characters).
Since the size attribute is a visual design attribute, we should use width in CSS instead.

CSS syntax: <input style="width:100px"/>

<<:  4 solutions to CSS browser compatibility issues

>>:  Detailed explanation of Vue project optimization and packaging

Recommend

Why the disk space is not released after deleting data in MySQL

Table of contents Problem Description Solution Pr...

Analysis of the process of building a LAN server based on http.server

I don’t know if you have ever encountered such a ...

Three solutions for sub-functions accessing external variables in JavaScript

Preface When we write web pages, we will definite...

Usage of Vue filters and timestamp conversion issues

Table of contents 1. Quickly recognize the concep...

Detailed explanation of jQuery chain calls

Table of contents Chain calls A small case Chain ...

Pricing table implemented with CSS3

Result: Implementation Code html <div id="...

Example code for implementing card waterfall layout with css3 column

This article introduces the sample code of CSS3 c...

How to build Git service based on http protocol on VMware+centOS 8

Table of contents 1. Cause 2. Equipment Informati...

Vue encapsulates the public function method of exporting Excel data

vue+element UI encapsulates a public function to ...

Website background music implementation method

For individual webmasters, how to make their websi...

ie filter collection

IE gave us a headache in the early stages of deve...

How to change password and set password complexity policy in Ubuntu

1. Change password 1. Modify the password of ordi...

MySQL column to row conversion tips (share)

Preface: Because many business tables use design ...