Mark Required Form Fields With an Asterisk
Adds a red asterisk after the label of every required field in standard HTML forms, so visitors can see at a glance what they must fill in.
Opens WPIDE on
Code
form label:not(:has(.required)):has(+ input[required])::after,
form label:not(:has(.required)):has(+ select[required])::after,
form label:not(:has(.required)):has(+ textarea[required])::after {
content: " *";
color: #c62828;
font-weight: 700;
}
Notes
Applies when the label sits directly before a field with the required attribute; labels that already contain a .required marker (like the comment form) are skipped.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.