Use a :before or :after pseudo-element on an input field - HTML CSS CSS Form

HTML CSS examples for CSS Form:input

Description

Use a :before or :after pseudo-element on an input field

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.field_with_errors {<!--from w  w w .  ja  va2 s.co m-->
   display:inline;
   color:Chartreuse;
}

.field_with_errors input+span:after {
   content:"*"
}
</style> 
 </head> 
 <body> 
  <div class="field_with_errors">
    Lorem ip 
  </div> 
  <div class="field_with_errors"> 
   <input type="text"> 
   <span></span> 
  </div>  
 </body>
</html>

Related Tutorials