In the world of web development, forms are a crucial element for user interaction and data collection. One of the most popular libraries for creating HTML forms is ’w3css’. The ’w3css’ library, part of the W3.CSS framework, offers a range of form elements and styling, helping developers create responsive, user-friendly forms. In this guide, we'll delve into a practical ’w3css’ form example, exploring its key features, structure, and usage.

Before we dive into the ’w3css’ form example, let's briefly understand the benefits of using ’w3css’ for form creation. ’W3.CSS’ ensures that your forms are fully responsive, adapting to different screen sizes, from desktop to mobile. It also provides a clean, modern look, improving the overall user experience. Plus, ’w3css’ is lightweight and easy to use, reducing your development time and effort.

Setting Up the ’w3css’ Form Environment
To get started with our ’w3css’ form example, we first need to include the ’w3.css’ library in our project. You can include it using a CDN (Content Delivery Network) or download and host it locally. Here's how you can add it via CDN:

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
Once the library is included, we can start building our form. Remember, ’w3css’ supports a 12-column grid system, which we'll be utilizing in our example.
Our ’w3css’ form example will feature a simple contact form, including fields for name, email, message, and a submit button. We'll use ’w3css’ classes like ’w3-input’, ’w3-btn’, ’w3-hover-blue’, and ’w3-circle’ for styling.

Creating Form Fields
Let's start by creating the input fields for name, email, and message. In ’w3css’, you can use the ’w3-input’ class to style your input fields. Here's how you can create a text input:
<input class="w3-input w3-border" type="text" placeholder="Name">
For email input, add the ’w3-validate=email’ attribute to ensure the input is a valid email address:

<input class="w3-input w3-border w3-validate" type="text" placeholder="Email">
And for the message input, we'll use a textarea:
<textarea class="w3-input w3-border" placeholder="Message"></textarea>
Creating the Submit Button
Now, let's create a submit button using the ’w3-btn’ class. We'll also add some hover effects with ’w3-hover-blue’ and round the corners with ’w3-circle’:

<button class="w3-btn w3-blue w3-hover-blue w3-circle">Submit</button>
Here's how our ’w3css’ form looks so far:
<form> <input class="w3-input w3-border" type="text" placeholder="Name"> <input class="w3-input w3-border w3-validate" type="text" placeholder="Email"> <textarea class="w3-input w3-border" placeholder="Message"></textarea> <button class="w3-btn w3-blue w3-hover-blue w3-circle">Submit</button> </form>
Laying Out the Form with Flexbox






![[2026 Full Guide] How to Fill Out a W-9 Form Correctly](https://i.pinimg.com/originals/75/71/c9/7571c9f9490d9adad9561585db0569e8.png)













Our form is functional, but it's not very organized yet. Let's improve its layout using ’w3css’ Flexbox. We'll wrap our form fields in a ’w3-row’ with a ’w3-center’ alignment, and use ’w3-col’ classes to create columns for each input field:
<form class="w3-center">
<div class="w3-row">
<div class="w3-col m6 w3-padding-16">
<input class="w3-input w3-border" type="text" placeholder="Name">
<input class="w3-input w3-border w3-validate" type="text" placeholder="Email">
</div>
<div class="w3-col m6 w3-padding-16">
<textarea class="w3-input w3-border" placeholder="Message"></textarea>
<button class="w3-btn w3-blue w3-hover-blue w3-circle">Submit</button>
</div>
</div>
</form>
With this layout, our form is now responsive and visually appealing, with inputs neatly organized in two columns.
Validating the Form
’W3.CSS’ also provides form validation features out of the box. For example, by adding the ’required’ attribute to our input fields and the ’w3-validate’ class, ’w3css’ will display validation messages when the form is submitted without completing the required fields:
<form class="w3-center w3-validate">
<div class="w3-row">
<div class="w3-col m6 w3-padding-16">
<input class="w3-input w3-border required" type="text" placeholder="Name">
<input class="w3-input w3-border w3-validate required" type="text" placeholder="Email">
</div>
<div class="w3-col m6 w3-padding-16">
<textarea class="w3-input w3-border required" placeholder="Message"></textarea>
<button class="w3-btn w3-blue w3-hover-blue w3-circle">Submit</button>
</div>
</div>
</form>
This improves the user experience by providing immediate feedback about what's missing or incorrect in the form.
In conclusion, ’w3css’ offers an extensive range of features for creating responsive, stylish, and user-friendly forms. Whether you're a seasoned developer or just starting out, incorporating ’w3css’ into your form-building workflow can significantly streamline your development process and enhance your users' experience. So why not give it a try in your next project? Happy coding!