Sample code for modifying the input prompt text style in html

Sample code for modifying the input prompt text style in html

On many websites, we have seen the input box display hint text. Let’s take a look at how to display hint text in the input box. We only need to add: placeholder="prompt text" in the <input> tag, so what if we want to change the style of the prompt text? You can set the css style like this:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>input box prompt text</title>
<style>
/*Change the color of the prompt text*/
input::-webkit-input-placeholder { /* WebKit browsers */ 
color: red; 
}
input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ 
color: red; 
}
input::-moz-placeholder { /* Mozilla Firefox 19+ */ 
color: red; 
}
input:-ms-input-placeholder { /* Internet Explorer 10+ */ 
color: red; 
}
</style>
</head>
<body>
<input type="text" placeholder="Please enter your username" />
</body>
</html>

The modified prompt text style is as follows:

PS: Let's take a look at the required attribute prompt text modification of the input tag in HTML5

When submitting a form, we sometimes encounter such a requirement. When the user submits without entering the required information, the prompt text needs to be changed to the prompt information we want. In this case, we can add the following statement in the input:

<input type="text" placeholder="Your name" required oninvalid="setCustomValidity('Please enter your name');" oninput="setCustomValidity('');" />

This is the end of this article about modifying the input prompt text style in html. For more relevant html input text style content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  How to use position:sticky to perfectly solve the problem of small programs adhering to the ceiling

>>:  Sharing some wonderful uses of wxs files in WeChat applet

Recommend

Detailed example of SpringBoot+nginx to achieve resource upload function

Recently, I have been learning to use nginx to pl...

The whole process of installing gogs with pagoda panel and docker

Table of contents 1 Install Docker in Baota Softw...

Native js implementation of slider interval component

This article example shares the specific code of ...

Building a Redis cluster on Docker

Table of contents 1. Pull the image 2. Create a R...

Vue implements simple comment function

This article shares the specific code of Vue to i...

Mini Program to Implement Paging Effect

This article example shares the specific code for...

Hide HTML elements through display or visibility

Sometimes we need to control whether HTML elements...

CSS mimics remote control buttons

Note: This demo is tested in the mini program env...

win2008 server security settings deployment document (recommended)

I had been working on the project before the New ...

CSS position fixed left and right double positioning implementation code

CSS Position The position attribute specifies the...

An example of how Vue implements four-level navigation and verification code

Effect: First create five vue interfaces 1.home.v...

Getting Started Guide to Converting Vue to React

Table of contents design Component Communication ...

MySQL 8 new features: Invisible Indexes

background Indexes are a double-edged sword. Whil...

Use of docker system command set

Table of contents docker system df docker system ...

What is Makefile in Linux? How does it work?

Run and compile your programs more efficiently wi...