Html required attribute and :invalid selector
We can fill input with error color when required field is empty using Html and Css only (without JavaScript).
Html과 Css만으로 필수 필드가 비었을 때 오류색상을 채울 수가 있다. (JavaScript를 사용하지 않고.)
괜찮구만. -- 2016-08-02
2. Sample
<h1>normal</h1> <input type="text" placeholder="" /> <h1>required (empty)</h1> <input type="text" required="required" /> <h1>required (not empty)</h1> <input type="text" required="required" value="value"/>
input { border: 1px solid #5f5; background-color: #efe; } input[required]:invalid { background-color: #fee; border: 1px solid #f55; }