Home >Web Front-end >CSS Tutorial >How to set text to be non-editable in css
How to set the text to be non-editable in css: 1. Set the text to be non-editable through the "οnfοcus=this.blur()" method; 2. Use the readonly attribute to set the input field to read-only; 3. Use the disabled attribute to set it Just disable the input element.
The operating environment of this tutorial: windows7 system, HTML5&&CSS3 version, Dell G3 computer.
Recommendation: css video tutorial
Method to set text to be non-editable
Method 1: οnfοcus=this.blur( ) Leave the focus when the mouse cannot be placed
<input type="text" name="input1" value="()" onfocus=this.blur()>
Method 2: Use the readonly attribute
Use the readonly attribute to specify that the input field is read-only and non-editable:
<html> <body> <form action="/example/html/form_action.asp" method="get"> <p>Name:<input type="text" name="email" /></p> <p>Country:<input type="text" name="country" value="China" readonly="true" /></p> <input type="submit" value="Submit" /> </form> </body> </html>
Rendering :
The above is the detailed content of How to set text to be non-editable in css. For more information, please follow other related articles on the PHP Chinese website!