Home Web Front-end CSS Tutorial What are css3 selectors: read-write and :read-only? how to use?

What are css3 selectors: read-write and :read-only? how to use?

Nov 24, 2018 am 10:15 AM
css3 Selector

This article brings you an introduction to the css3 selectors: read-write and: read-only. How to use it, let everyone know what the :read-write selector and :read-only selector of CSS3 are, what they do, and how to use them. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

css3 :read-write

:read-write is a pseudo-class selector in CSS, which is used to match user-editable elements, that is, readable and writable elements.

Elements belonging to the editable category include:

1. elements (of any type) that are not read-only and not disabled. This means that they have neither the readonly nor the disabled attribute set.

2. A

3. Any other element that is not or

Note: Currently, in most browsers, the :read-write selector can only be used to set input and textarea elements.

css3 :read-only

:read-only is also a pseudo-class selector in CSS, matching anything that does not match the :read-write selector element.

In other words, the :read-only pseudo-class selector matches elements that cannot be edited by the user, that is, it matches any element that is not editable above . For example: elements with attributes such as readonly or disabled set.

The following are examples of elements that can be matched using: read-write:

< input  type = “text” >
< input  type = “number” >
< textarea  name = “nm”  id = “id”  cols = “30”  rows = “10” >  </ textarea >
< div  class = “random”  contenteditable >  </ div >
Copy after login

The following are examples of elements that cannot be matched using: read-write, that is, examples of elements that can be matched using: read-only :

< input  type = “text”  disabled >
< input  type = “number”  disabled >
< input  type = “number”  readonly >
< textarea  name = “nm”  id = “id”  cols = “30”  rows = “10”  readonly >  </ textarea >
< div  class = “random” >  </ div >  <! - 无法使用contenteditable编辑的常规元素 - >
Copy after login

Although this is the behavior recommended by the specification, browser behavior appears to vary: what may be considered read and write in one browser will be considered read and written in another browser. Read-only, so the :read-write style we apply may not work with some browsers.

Like other pseudo-class selectors, both the :read-write selector and the :read-only selector can be linked with other selectors, such as :hover and the pseudo-element ::after.

For example, :read-write :focus will provide the style for the editable text area:

textarea:read-write:focus {
    box-shadow: 0 0 2px 1px rgba(0,0,0,0.2);
}

textarea:read-write:before {
    content: "Type here...";
    color: #aaa;
}
Copy after login

For example, :read-only :hover will provide the style for the div (regular) on the page:

div:read-only:hover {
    background-color: #eee;
}

div:read-only:before {
    content: "?";
    color: deepPink;
}
Copy after login

Browser support

What are css3 selectors: read-write and :read-only? how to use?The number in the table indicates the first browser version number that supports this attribute.

In Firefox browser, use the prefix: -moz-read-write, -moz-read-only; and the read-write selector and read-only selector are not supported on Internet Explorer and Android use.

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study. Recommended related video tutorials: CSS3 tutorial!

The above is the detailed content of What are css3 selectors: read-write and :read-only? how to use?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement lace borders in css3 How to implement lace borders in css3 Sep 16, 2022 pm 07:11 PM

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

What is the identifier of the id selector in css What is the identifier of the id selector in css Sep 22, 2022 pm 03:57 PM

In CSS, the identifier of the id selector is "#". You can specify a specific style for the HTML element marked with a specific id attribute value. The syntax structure is "#ID value {attribute: attribute value;}". The ID attribute is unique and non-repeatable in the entire page; the ID attribute value should not start with a number. IDs starting with numbers will not work in Mozilla/Firefox browsers.

Use the :nth-child(n+3) pseudo-class selector to select the style of child elements whose position is greater than or equal to 3 Use the :nth-child(n+3) pseudo-class selector to select the style of child elements whose position is greater than or equal to 3 Nov 20, 2023 am 11:20 AM

Use the :nth-child(n+3) pseudo-class selector to select the style of child elements whose position is greater than or equal to 3. The specific code example is as follows: HTML code: &lt;divid="container"&gt;&lt;divclass="item"&gt ;First child element&lt;/div&gt;&lt;divclass="item"&

What to do if the javascript selector fails What to do if the javascript selector fails Feb 10, 2023 am 10:15 AM

The JavaScript selector fails because the code is not standardized. The solution is: 1. Remove the imported JS code and the ID selector method will be effective; 2. Just introduce the specified JS code before introducing "jquery.js".

Learn new CSS features: Directional clipping overflow:clip Learn new CSS features: Directional clipping overflow:clip Oct 11, 2022 pm 07:12 PM

This article will introduce a new feature, starting from Chrome 90, a new feature added to overflow - overflow: clip. Use it to easily control the overflow direction.

Do selectors in css include hypertext tag selectors? Do selectors in css include hypertext tag selectors? Sep 01, 2022 pm 05:25 PM

Not included. CSS selectors include: 1. Tag selector, which locates specific HTML elements through the element name of the HTML page; 2. Class selector, which locates specific HTML elements through the value of the class attribute of the HTML element; 3. ID selector, which Locate specific HTML elements through the value of the id attribute of the HTML element; 4. The wildcard selector "*" can refer to all types of tag elements, including custom elements; 5. The attribute selector uses the existing attribute name of the HTML element or attribute value to locate a specific HTML element.

In-depth analysis of is and where selectors: improving CSS programming level In-depth analysis of is and where selectors: improving CSS programming level Sep 08, 2023 pm 08:22 PM

In-depth analysis of is and where selectors: improving the level of CSS programming Introduction: In the process of CSS programming, selectors are an essential element. They allow us to select and style elements in an HTML document based on specific criteria. In this article, we will take a deep dive into two commonly used selectors namely: is selector and where selector. By understanding their working principles and usage scenarios, we can greatly improve the level of CSS programming. 1. is selector is selector is a very powerful choice

Detailed explanation of using SVG to add logo to favicon Detailed explanation of using SVG to add logo to favicon Sep 07, 2022 am 10:30 AM

How to add logo to favicon using SVG? The following article will introduce to you how to use SVG to generate favicon with logo. I hope it will be helpful to you!

See all articles