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

Solution to mysql prompt "got timeout reading communication packets"

Error message: user: 'root' host: `localh...

MySQL 8.0.11 Installation Tutorial under Windows

This article records the installation tutorial of...

MySQL InnoDB transaction lock source code analysis

Table of contents 1. Lock and Latch 2. Repeatable...

MySQL 5.7.18 download and installation process detailed instructions

MySql Download 1. Open the official website and f...

The complete process of Docker image creation

Table of contents Preface Creation steps Create a...

Implementation code for operating mysql database in golang

Preface Golang provides the database/sql package ...

MySQL data operation-use of DML statements

illustrate DML (Data Manipulation Language) refer...

The difference and choice between datetime and timestamp in MySQL

Table of contents 1 Difference 1.1 Space Occupanc...

VUE+SpringBoot implements paging function

This article mainly introduces how to implement a...

jQuery simulates picker to achieve sliding selection effect

This article shares the specific code of jQuery t...

Teach you 10 ways to center horizontally and vertically in CSS (summary)

A must-have for interviews, you will definitely u...

How to build a deep learning environment running Python in Docker container

Check virtualization in Task Manager, if it is en...

Several methods to execute sql files under mysql command line

Table of contents The first method: When the MySQ...