fieldset{ width: 300px; margin-bottom: 10px; } .red{ color: black; } input, label{ margin: 3px 0px; } textarea{ width: 100%; } input[type="text"],input[type="email"]{ float: right; clear: right; } label{ float: left; clear: left; } input:required + label:after{ content: ' *'; color: black; }
<!doctype html> <html> <head> <title>Adding * to requested fields</title> </head> <body> <form> <fieldset> <legend>Basic information:</legend> <input type="text" name="title" placeholder="es: Mr" required><label for="title">Title:</label> <input type="text" name="nome" placeholder="es: Sandro" required><label for="nome">Name:</label> <input type="text" name="cognome" placeholder="es: Paganotti" required><label for="cognome">Surname:</label> </fieldset> <fieldset> <legend>Your thoughts:</legend> <textarea name="commento"></textarea> </fieldset> <small><span class='red'>*</span> this a requested field</small><br/> <input type="submit" value="Send this form"> </form> </body> </html>