| <!doctype html> |
| <html> |
| <head> |
| <style> |
| form, fieldset { |
| padding: 5px; |
| margin: 2px; |
| border: 1px solid black; |
| } |
| :matches(form, fieldset):valid { |
| background-color: green; |
| } |
| :matches(form, fieldset):not(:valid) { |
| background-color: red; |
| } |
| /* Pack them to fit everything in 800*600 */ |
| body > :not(p) { |
| float: left; |
| } |
| </style> |
| </head> |
| <body> |
| <p>Test the basics of the pseudo class :valid with the <form> and <fieldset> elements.</p> |
| |
| <!-- Empty stuff. --> |
| <form> |
| <fieldset></fieldset> |
| </form> |
| |
| <!-- Basic input as a descendant. --> |
| <form> |
| <fieldset> |
| <input> |
| </fieldset> |
| </form> |
| |
| <!-- Basic input associated. --> |
| <div> |
| <form id="basic_input1"> |
| <fieldset></fieldset> |
| </form> |
| <fieldset form="basic_input1"> |
| <input> |
| </fieldset> |
| </div> |
| |
| <div> |
| <form id="basic_input2"> |
| <fieldset></fieldset> |
| </form> |
| <fieldset> |
| <input form="basic_input2"> |
| </fieldset> |
| </div> |
| |
| <!-- Required input as a descendant. --> |
| <form> |
| <fieldset> |
| <input required> |
| </fieldset> |
| </form> |
| |
| <!-- Required input associated. --> |
| <div> |
| <form id="required_input1"> |
| <fieldset></fieldset> |
| </form> |
| <fieldset> |
| <input form="required_input1" required> |
| </fieldset> |
| </div> |
| |
| <div> |
| <form id="required_input2"> |
| <fieldset></fieldset> |
| </form> |
| <fieldset form="required_input2"> |
| <input required> |
| </fieldset> |
| </div> |
| |
| <!-- Valid required input as a descendant. --> |
| <form> |
| <fieldset> |
| <input value="WebKit!" required> |
| </fieldset> |
| </form> |
| |
| <!-- Valid required input associated. --> |
| <div> |
| <form id="valid_required_input1"> |
| <fieldset></fieldset> |
| </form> |
| <fieldset> |
| <input value="WebKit!" form="valid_required_input1" required> |
| </fieldset> |
| </div> |
| <div> |
| <form id="valid_required_input2"> |
| <fieldset></fieldset> |
| </form> |
| <fieldset form="valid_required_input2"> |
| <input value="WebKit!" required> |
| </fieldset> |
| </div> |
| </body> |
| </html> |