CHAPTER 37

CSS Forms

Learn how to create clean, professional and responsive form designs using CSS.

01. What is CSS Forms?

Forms collect information from website users.
CSS can style inputs, labels, buttons, textareas and select boxes.
Good form design improves usability and user experience.

02. Syntax

input { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 8px; }

03. Example

CSS / HTML Example AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>

<style>

.form {

    max-width: 450px;

    margin: auto;

}

label {

    display: block;

    margin-bottom: 6px;

    font-weight: bold;

}

input,
textarea,
select {

    width: 100%;

    padding: 12px;

    margin-bottom: 18px;

    border: 1px solid #cbd5e1;

    border-radius: 8px;

}

button {

    width: 100%;

    padding: 13px;

    border: none;

    border-radius: 8px;

    background: #2563eb;

    color: white;

}

</style>

</head>

<body>

<form class="form">

    <label>Name</label>

    <input type="text">

    <label>Email</label>

    <input type="email">

    <label>Message</label>

    <textarea rows="5"></textarea>

    <button>
        Submit
    </button>

</form>

</body>
</html>

04. Important Points

✓ Use clear labels for form controls.
✓ Inputs should be easy to identify and use.
✓ Focus states should be visible.
✓ Forms should work well on mobile screens.

05. Common Mistakes

⚠ Using very small input fields.
⚠ Removing focus outlines without alternatives.
⚠ Using low-contrast placeholder text.
⚠ Creating forms wider than the mobile screen.

06. Real World Use

CSS forms are used for admissions, login pages, contact forms, registration, enquiries and online applications.

Ready to Practice? 🚀

Open the AIFA CSS Editor and practice this chapter live.

Try It Yourself →
Practice Exercise

Create an Admission Form

Create a responsive admission form containing Name, Email, Phone, Course and Message fields.