Toggle navigation
☰
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html> <head> <title>Fieldset and Legend Example</title> <style> body { font-family: sans-serif; margin: 20px; background-color: #fcfcfc; } form { max-width: 400px; } fieldset { background-color: white; border: 1px solid #ccc; border-radius: 8px; padding: 20px; margin-bottom: 25px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); } legend { background-color: #007bff; color: white; padding: 5px 15px; border-radius: 4px; font-weight: bold; font-size: 14px; } .form-group { margin-bottom: 15px; } .form-group label { display: block; margin-bottom: 5px; font-size: 14px; } .form-group input[type="text"], .form-group input[type="email"] { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } .radio-group label { display: block; margin-bottom: 5px; font-weight: normal; } button[type="submit"] { background-color: #28a745; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: bold; } button[type="submit"]:hover { background-color: #218838; } </style> </head> <body> <form action="/submit" method="post"> <fieldset> <legend>Personal Information</legend> <div class="form-group"> <label for="fname">First Name</label> <input type="text" id="fname" name="fname"> </div> <div class="form-group"> <label for="lname">Last Name</label> <input type="text" id="lname" name="lname"> </div> </fieldset> <fieldset> <legend>Subscription Preferences</legend> <div class="radio-group"> <label><input type="radio" name="sub_type" value="daily" checked> Daily Newsletter</label> <label><input type="radio" name="sub_type" value="weekly"> Weekly Digest</label> <label><input type="radio" name="sub_type" value="none"> Unsubscribe</label> </div> </fieldset> <button type="submit">Update Preferences</button> </form> </body> </html>