:placeholder-shown
Quick Summary for :placeholder-shown
			    The 
			:placeholder-shown CSS pseudo-class represents any <input> or <textarea> element that is currently displaying placeholder text.
			  Code Usage for :placeholder-shown
/* Selects any element with an active placeholder */ :placeholder-shown {   border: 2px solid silver; } More Details for :placeholder-shown
:placeholder-shown
The :placeholder-shown CSS pseudo-class represents any <input> or <textarea> element that is currently displaying placeholder text.
/* Selects any element with an active placeholder */ :placeholder-shown {   border: 2px solid silver; } Syntax
:placeholder-shown
Examples
Basic example
This example applies special font and border styles when the placeholder is shown.
HTML<input placeholder="Type something here!"> input {   border: 1px solid black;   padding: 3px; }  input:placeholder-shown {   border-color: teal;   color: purple;   font-style: italic; } Overflowing text
When form fields are too small, placeholder text can get cropped in an undesirable way. You can use the text-overflow property to alter the way overflowing text is displayed.
<input id="input1" placeholder="Name, Rank, and Serial Number"> <br><br> <input id="input2" placeholder="Name, Rank, and Serial Number"> #input2:placeholder-shown {   text-overflow: ellipsis; } Customized input field
The following example highlights the Branch and ID code fields with a custom style.
HTML<form id="test">   <p>     <label for="name">Enter Student Name:</label>     <input id="name" placeholder="Student Name"/>   </p>   <p>     <label for="branch">Enter Student Branch:</label>     <input id="branch" placeholder="Student Branch"/>   </p>   <p>     <label for="sid">Enter Student ID:</label>     <input type="number" pattern="[0-9]{8}" title="8 digit ID" id="sid" class="studentid" placeholder="8 digit id"/>   </p>   <input type="submit"/> </form> input {   background-color: #E8E8E8;   color: black; }  input.studentid:placeholder-shown {   background-color: yellow;   color: red;   font-style: italic; } Specifications
| Specification | 
|---|
| Selectors Level 4 # placeholder | 
See also
The::placeholder pseudo-element styles the placeholder itself.   Related HTML elements: <input>, <textarea>   HTML forms Select your preferred language English (US)DeutschEspañolFrançais日本語Русский中文 (简体) Change language
			   Posted in   
      12:22 am, February 22, 2022 
    Add Comment
Other Items in CSS
      rgb()
rgba()
:right
right
@right-bottom
:root
rotate
rotate()
rotate3d()
rotateX()
rotateY()
rotateZ()
row-gap
ruby-align
ruby-position
saturate()
scale
scale()
scale3d()
scaleX()
scaleY()
scaleZ()
:scope
scroll-behavior
scroll-margin
scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-stop
scroll-snap-type
@scroll-timeline
    
   
	