Detailed explanation of HTML form elements (Part 2)

Detailed explanation of HTML form elements (Part 2)

HTML Input Attributes

The value attribute

The value attribute specifies the initial value of the input field:

<form action="">
<input type="text" name="name" value="123WORDPRESS.COM">
</form>

readonly attribute

The readonly attribute specifies that an input field is read-only (cannot be modified):

<form action="">
<input type="text" name="name" value="123WORDPRESS.COM" readonly>
</form>

A readonly attribute does not require a value. It is equivalent to readonly="readonly".

The disabled attribute

The disabled attribute specifies that the input field is disabled;
Disabled elements are unavailable and unclickable;
Disabled elements will not be submitted.

<form action="">
<input type="text" name="name" value="123WORDPRESS.COM" disabled >
</form>

The disabled attribute does not require a value. This is equivalent to disabled="disabled".

size attribute

The size attribute specifies the size of the input field in characters:

<form action="">
<input type="text" name="name" value="123WORDPRESS.COM" size="40">
</form>

The maxlength attribute

The maxlength attribute specifies the maximum length allowed for an input field:

<form action="">
<input type="text" name="name" value="123WORDPRESS.COM" maxlength="10">
</form>

If the maxlength attribute is set, the input control will not accept more characters than the allowed number.
This property does not provide any feedback. If you need to alert the user, you must write JavaScript code.
NOTE: Input restrictions are not foolproof. JavaScript provides many ways to add invalid input. To restrict input securely, the recipient (server) must also check the restrictions.

The width attribute

Defines the width of the input field. (Applicable to type="image"):

<form action="">
<input type="image" name="img" src="xxx.jpg" width="100">
</form>

height property

Defines the height of the input field. (Applicable to type="image"):

<form action="">
<input type="image" name="img" src="xxx.jpg" height="100">
</form>

src Attribute

Defines the URL of an image to be displayed in the submit button form:

<form action="">
<input type="image" name="img" src="xxx.jpg" width="100">
</form>

name attribute

Define the name of the input element:

<form action="">
<input type="image" name="img" src="xxx.jpg" width="100">
</form>

The checked attribute

Specifies that this input element should be selected when first loaded:

<form action="">
<input type="radio" name="single choice" checked>
</form>

The accept attribute

Specifies the type of file to be submitted via file upload:

<form action="">
<input type="file" name="Upload file" accept="text/css">
</form>  

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM!

<<:  Detailed tutorial on Apache source code installation and virtual host configuration

>>:  Detailed explanation of the use of various MySQL indexes

Recommend

Docker data storage tmpfs mounts detailed explanation

Before reading this article, I hope you have a ba...

Use docker to deploy tomcat and connect to skywalking

Table of contents 1. Overview 2. Use docker to de...

Summary of methods for inserting videos into HTML pages

Now if you want to use the video tag in a page, y...

Let you understand how HTML and resources are loaded

All content in this blog is licensed under Creati...

Two implementation codes of Vue-router programmatic navigation

Two ways to navigate the page Declarative navigat...

Implementation of vscode custom vue template

Use the vscode editor to create a vue template, s...

Four modes of Oracle opening and closing

>1 Start the database In the cmd command windo...

Detailed tutorial on compiling and installing MySQL 8.0.20 from source code

In the previous article, we introduced: MySQL8.0....

How to implement an array lazy evaluation library in JavaScript

Table of contents Overview How to achieve it Spec...

Vue routing relative path jump method

Table of contents Vue routing relative path jump ...

Vue conditional rendering v-if and v-show

Table of contents 1. v-if 2. Use v-if on <temp...

Sqoop export map100% reduce0% stuck in various reasons and solutions

I call this kind of bug a typical "Hamlet&qu...

The most common mistakes in HTML tag writing

We better start paying attention, because HTML Po...

JS+Canvas realizes dynamic clock effect

A dynamic clock demo based on Canvas is provided ...