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

Raspberry Pi msmtp and mutt installation and configuration tutorial

1. Install mutt sudo apt-get install mutt 2. Inst...

Practical tutorial on modifying MySQL character set

Preface: In MySQL, the system supports many chara...

Teach you how to achieve vertical centering elegantly (recommended)

Preface There are many ways to center horizontall...

Tips on HTML formatting and long files for web design

<br />Related articles: 9 practical suggesti...

css3 animation ball rolling js control animation pause

CSS3 can create animations, which can replace man...

What kinds of MYSQL connection queries do you know?

Preface If the query information comes from multi...

Detailed tutorial on installing MySQL database on Alibaba Cloud Server

Table of contents Preface 1. Uninstall MySQL 2. I...

Methods and steps for Etcd distributed deployment based on Docker

1. Environmental Preparation 1.1 Basic Environmen...

Detailed process of installing nginx1.9.1 on centos8

1.17.9 More delicious, really Nginx download addr...

Vue codemirror realizes the effect of online code compiler

Preface If we want to achieve the effect of onlin...

Alibaba Cloud Server Domain Name Resolution Steps (Tutorial for Beginners)

For novices who have just started to build a webs...

The difference between clientWidth, offsetWidth, scrollWidth in JavaScript

1. Concept They are all attributes of Element, in...