Home  >  Article  >  Web Front-end  >  How to use html hidden attributes

How to use html hidden attributes

coldplay.xixi
coldplay.xixiOriginal
2021-04-27 11:35:156252browse

htmlHow to use hidden attributes: 1. Use disabled to disable the input element; 2. readonly specifies whether the input field is read-only; 3. When the hidden attribute value is true, the element is hidden on the interface; 4 . The display value is none, which means that this element will not be displayed.

How to use html hidden attributes

The operating environment of this tutorial: windows7 system, html5 version, DELL G3 computer.

htmlHow to use hidden attributes:

1. disabled. The HTML input tag has a disabled attribute, which specifies whether the input element is disabled. A disabled input element is neither available nor clickable, and the value is "disabled". If you want to enable the input element, you can remove the disabled value through JavaScript. Disabled elements cannot obtain the cursor or focus. The value can only be set through JavaScript. The user cannot modify it on the interface, and the value will not be submitted to the background when submitted.

2. readonly. The HTML input tag has a readonly attribute, which specifies whether the input field is read-only. Read-only elements cannot be entered, and the value is "readonly". If you want to make it writable, you can only clear the readonly value through JavaScript. The value of an element set as read-only through readonly can only be set through JavaScript. The user cannot modify it on the interface and can obtain the cursor or focus. When submitting, the value will be submitted to the background. This is the biggest difference from disabled.

3. hidden. The values ​​of this attribute are true and false. When the value of this attribute is true, the element is hidden on the interface and the value of the element can only be set through JavaScript. The user cannot see the element on the interface. This is the difference from disabled and readonly. The value will be submitted to the background when submitted.

4. display. This property is used to set how the element is displayed. Commonly used values ​​are: none, block, inline, inline-table. none means that this element will not be displayed; block means that this element will be displayed as a block-level element, with line breaks before and after this element; inline means that this element will be displayed as an inline element, with no line breaks before and after the element, which is the default Value; inline-table means that this element will be displayed as an inline table (similar to a table), with no line breaks before and after the table. When set to none, the element will be hidden and will not take up page space. If there are three div elements from top to bottom on the page, and the display attribute of the second div element is set to none, then only two div elements can be seen on the interface, and they are right next to each other.

Related learning recommendations: html video tutorial

The above is the detailed content of How to use html hidden attributes. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn