Want to create polished and user-friendly Gravity Forms? This guide breaks down how to style and customize forms using CSS for better usability and aesthetics. Whether you’re dealing with misaligned fields, clunky layouts, or inconsistent branding, CSS offers the flexibility to fix these issues and improve user experience across devices.
Key Takeaways:
- Understand Gravity Forms’ CSS Structure: Forms are wrapped in
.gform_wrapperwith fields organized in.gfieldelements. - Use Built-in Tools First: Features like the Appearance tab and CSS Ready Classes simplify layout adjustments (e.g., multi-column forms).
- Custom CSS for Precision: Target specific fields, buttons, or error messages using unique form and field IDs.
- Responsive Design: Use Flexbox, Grid, and media queries to ensure forms work seamlessly on desktops and mobile devices.
- Avoid Common Issues: Theme conflicts? Use scoped selectors or increase CSS specificity to fix overrides.
Example CSS Tricks:
- Limit a field’s width:
#input_2_6 { max-width: 120px; } - Style error messages:
.gfield_error .gfield_validation_message { color: #b00020; font-weight: bold; } - Mobile-friendly buttons:
.gform_footer input[type="submit"] { width: 100%; padding: 1rem; }
Next Steps: Start with Gravity Forms’ built-in tools, then layer on custom CSS for advanced tweaks. Test your forms on various devices to ensure they’re user-friendly everywhere. For more advanced tips, explore resources like WP Winners to refine your form-building skills.
Gravity Forms CSS Classes tutorial – Styling your forms
Gravity Forms CSS Structure Basics

Gravity Forms CSS Structure and Selector Hierarchy Guide
Before diving into custom CSS for Gravity Forms, it’s essential to understand its HTML structure and the associated CSS classes. Every form is enclosed in a .gform_wrapper container, which acts as the outermost boundary for styling. Within this container, you’ll find .gform_body, which holds all the form fields, and .gform_footer, which contains the submit button. Each field is wrapped in an <li> element with the class .gfield, responsible for organizing layout, labels, and error messages. [1][2]
Main Selectors and Classes
The .gform_wrapper is your go-to selector for applying global styles to a form, such as background colors, padding, max-width, or typography, without affecting other elements on the page. To target a specific form, use #gform_wrapper_X, where "X" is the form number. For individual fields, Gravity Forms uses #field_X_Y (X represents the form ID, and Y is the field ID). Inputs within these fields are identified by #input_X_Y, and for multi-input fields like "Name", an additional index may appear, such as #input_2_5_3. This predictable naming system allows for highly specific rules. For instance, if you need to limit the width of a ZIP code field in form 2, you could use:
#input_2_6 { max-width: 120px; }
Within each .gfield, you’ll typically find elements like .gfield_label for the label, .ginput_container for the input field, and optional components like .gfield_description or .gfield_validation_message, which handle help text and error messages. Checkbox and radio fields include additional classes, such as .gfield_checkbox, .gfield_radio, and .gchoice, which wrap each option. [1][2][3]
Gravity Forms also uses state-specific modifier classes to handle dynamic behaviors. For example:
.gfield_error: Marks fields with validation errors..gfield_contains_required: Flags required fields..gfield_visibility_visible: Indicates conditional logic states.
These classes make it easy to style validation errors, add custom indicators for required fields, or animate transitions for conditional logic. This structure provides flexibility for both broad and detailed adjustments.
| Key Selector | Description | Example Usage |
|---|---|---|
.gform_wrapper |
Outermost form container | .gform_wrapper { background: #f9f9f9; padding: 20px; } [1][5] |
.gfield |
Individual form field | .gfield { margin-bottom: 15px; } [1] |
#field_xx_yy |
Specific field by form/field ID | #field_1_5 { border: 1px solid #ccc; } [1] |
.gchoice |
Checkbox/radio options | .gchoice label { font-weight: bold; } [3] |
Element Hierarchy
Gravity Forms generate a <form> element that contains the .gform_wrapper, which houses .gform_body. Inside .gform_body, fields are listed within a <ul> element, with each field as an <li> tagged with .gfield and a unique ID. Nested within these fields are the label, input container, and optional description or error elements, arranged in that order. [1][2]
This hierarchy allows for precise targeting with CSS. For example, if you want to style error messages for a specific form, you could use:
#gform_wrapper_5 .gfield.gfield_error .gfield_validation_message { color: #b00020; font-weight: 600; }
To avoid conflicts with your WordPress theme or other forms, it’s recommended to scope your selectors with the form ID. For instance, using .gform_wrapper .gfield alone might be overridden by theme styles, but #gform_wrapper_10 .gfield ensures your changes apply only to form 10. [1][4] Once you’ve mastered these basics, you can explore built-in styling options to refine your form’s appearance.
Built-in Styling Options
Gravity Forms offers a user-friendly way to create polished forms without needing to dive into CSS. With built-in layout and styling controls, you can adjust field sizes, label placement, colors, and even create multi-column layouts – all directly within the editor. For U.S. businesses or agencies needing quick solutions for forms like contact requests, lead capture, or event registrations, these tools often get the job done without requiring additional customization.
Two key features to explore are the Appearance tab (available in each field’s settings and at the form level) and CSS Ready Classes (pre-defined class names for instant layout adjustments). These tools allow users to create side-by-side fields, tweak input widths, control label visibility, and style buttons to match their branding – all from the editor interface. Since Gravity Forms 2.7, the Orbital theme and block editor controls have made it even easier to customize elements like input borders, label fonts, and button colors without writing a single line of CSS.
Using the Appearance Tab
When you select a field in the Form Editor, the Appearance tab appears in the sidebar on the right. This tab lets you control the field’s visual settings. For example, you can adjust the field size (Small, Medium, or Large) to set the input’s width within its column. You can also manage label visibility, choosing to show, hide, or use the label as a placeholder, which is great for creating clean, compact layouts. If your field includes help text, the Appearance tab lets you decide whether descriptions or sub-labels appear above or below the input.
At the form level, go to Settings → Form Settings → Form Layout to apply global styling. Here, you can set Label Placement (above, to the left, or to the right of the input) and Description Placement for consistent formatting across all fields. The Appearance tab also includes a Custom CSS Class input box, where you can add Ready Classes or theme-specific class names for layout tweaks. For example, a U.S.-based e-commerce form might use this feature to make ZIP code fields more compact or to position help text neatly below payment inputs.
If you’re using the Orbital theme (available in Gravity Forms 2.7+), you can further refine the look of your forms directly from the block editor or theme settings. You can customize input border radius for a modern design, adjust label font size and color for better readability, and style submit buttons to match your brand. For instance, a U.S. business might opt for larger font sizes to enhance accessibility, use darker label colors for better contrast, and style the submit button with brand colors – like a blue (#204ce5) background with white text – to make the call-to-action stand out.
For more advanced layout adjustments without custom code, check out the section on Applying Ready Classes.
Applying Ready Classes
CSS Ready Classes are pre-defined class names built into Gravity Forms’ stylesheet that enable quick, common layout adjustments. These classes are especially helpful for U.S. marketers or agencies who need responsive, professional-looking forms for tasks like gathering contact info, requesting quotes, or managing event registrations – without relying on a developer. Keep in mind that these classes only affect the front-end display, not the Form Editor itself.
To use a Ready Class, open the field in the Form Editor, navigate to the Appearance tab, and enter the class name in the Custom CSS Class field. You can combine multiple classes by separating them with a space (e.g., gf_left_half gf_inline). For global layout changes, go to Settings → Form Settings → Form Layout and add the class name in the CSS Class Name box.
Here are some commonly used Ready Classes:
gf_left_halfandgf_right_half: Create two equal columns.gf_left_third,gf_middle_third, andgf_right_third: Set up a three-column layout.gf_inline: Display checkboxes or radio buttons horizontally instead of stacking them.
For example, when designing a U.S. address form, you can apply gf_left_half to the "City" field and gf_right_half to the "State" field for a side-by-side layout. Then, use gf_left_half for the "ZIP Code" field to keep it compact and visually balanced. This approach improves readability and reduces unnecessary scrolling.
Ready Classes are designed with mobile responsiveness in mind, so multi-column layouts will automatically collapse into a single column on smaller screens. Always use the Preview function to check how your form looks on different devices, ensuring that spacing, tap targets, and readability remain user-friendly across all screen sizes.
Advanced CSS Customizations
Once you’ve mastered the basics of CSS and the built-in options, advanced customizations allow you to fine-tune every detail of your forms. This is particularly handy for U.S. businesses that need their forms to meet strict brand guidelines – whether it’s matching specific hex colors, designing custom button styles, or building complex multi-column layouts. Gravity Forms generates consistent HTML with classes and IDs [2][5], making it easy to target elements precisely without unintentionally affecting others.
The trick to successful advanced customization lies in knowing where to add your CSS and how to scope it effectively. For minor tweaks, use the WordPress Customizer. For more extensive changes, work with a child theme’s style.css. Avoid editing parent theme files directly, as updates can overwrite your changes.
Adding Custom CSS to WordPress
To add custom CSS using the WordPress Customizer, go to Appearance → Customize → Additional CSS. Paste your Gravity Forms styles into the provided field and click "Publish."
For larger projects, especially those handled by agencies, a child theme is the better option. Add or update the style.css file in your child theme directory, and ensure it’s properly enqueued in the functions.php file. If you’re using a page builder like Elementor or Beaver Builder, you can also add CSS through their global CSS panels. However, keep in mind that tying your CSS to a builder can complicate migrations or theme changes.
Always scope your selectors to avoid unintended styling issues. Gravity Forms assigns unique IDs to each form wrapper (e.g., #gform_wrapper_1) and field (e.g., #field_1_3). For example, to style the email input field in form ID 1 (field ID 3), you could use this CSS:
#gform_wrapper_1 #field_1_3 .ginput_container input[type="email"] { border: 2px solid #0f6ad8; border-radius: 4px; }
Alternatively, add a custom class in Form Settings → Form Layout → CSS Class Name (e.g., lead-gen-form) and use it in your selectors:
.lead-gen-form .gform_wrapper .gfield input[type="text"] { /* Your custom styles */ }
With these techniques, you can customize specific form elements with precision.
Styling Specific Form Elements
Gravity Forms uses shared utility classes across all forms, making it easy to apply consistent styles. For example, text inputs, email fields, phone fields, textareas, and dropdowns are all wrapped in .ginput_container. You can style them collectively or individually:
.gform_wrapper .gfield input[type="text"], .gform_wrapper .gfield input[type="email"], .gform_wrapper .gfield input[type="tel"], .gform_wrapper .gfield textarea, .gform_wrapper .gfield select { width: 100%; padding: 0.75rem 1rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 16px; } .gform_wrapper .gfield input:focus, .gform_wrapper .gfield textarea:focus, .gform_wrapper .gfield select:focus { border-color: #2563eb; box-shadow: 0 0 0 1px #2563eb; outline: none; }
For checkboxes and radio buttons, you can create custom designs by hiding the default controls while keeping them accessible. Use the .gfield-choice-input and .gchoice label classes for this:
/* Hide the native input but keep it accessible */ .gfield-choice-input { position: absolute; opacity: 0; } /* Style the label like a button */ .gchoice label { display: inline-block; padding: 0.5rem 0.9rem; border-radius: 9999px; border: 1px solid #d1d5db; cursor: pointer; transition: all 0.2s ease-in-out; } /* Checked state styling */ .gfield-choice-input:checked + label { background-color: #2563eb; color: #ffffff; border-color: #2563eb; }
Submit buttons are another frequent target for customization. You can match them to your brand’s colors and add hover effects for interactivity:
.gform_wrapper .gform_footer input[type="submit"] { background-color: #16a34a; color: #ffffff; padding: 0.85rem 1.8rem; border-radius: 9999px; border: none; font-size: 17px; font-weight: 600; cursor: pointer; transition: background-color 0.15s ease-in-out, transform 0.1s ease-in-out; } .gform_wrapper .gform_footer input[type="submit"]:hover { background-color: #15803d; transform: translateY(-1px); }
For mobile users, setting width: 100% ensures buttons are full-width and easy to tap.
Creating Multi-Column Layouts
For multi-column layouts – like U.S. address forms (City / State / ZIP) or lead-generation forms – use Flexbox or CSS Grid for precision.
To make a Flexbox-based two-column layout, add a custom class (e.g., two-column-form) in Form Settings → Form Layout → CSS Class Name, then use the following CSS:
.two-column-form .gform_fields { display: flex; flex-wrap: wrap; gap: 1.5rem; } .two-column-form .gfield { flex: 1 1 calc(50% - 1.5rem); } @media (max-width: 768px) { .two-column-form .gfield { flex-basis: 100%; } }
For more precise control, CSS Grid is ideal. For example, to create a 2:1:1 layout for City, State, and ZIP fields, use this:
.grid-form .gform_fields { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0.75rem; }
These techniques let you create professional, polished forms that fit seamlessly into your website’s design.
sbb-itb-77ae9a4
Making Forms Responsive
Creating a responsive Gravity Form means ensuring it adjusts seamlessly across devices, from desktops to smartphones. While Gravity Forms includes basic responsive features, custom themes or CSS can sometimes interfere, causing issues like fixed-width elements that don’t adapt well to smaller screens. To avoid this, use relative units like percentages (%), em, or rem instead of fixed pixels. Also, make sure touch targets are large enough for easy interaction and arrange multi-column layouts into a single column on smaller screens.
With over 50% of U.S. website traffic coming from smartphones, optimizing forms for mobile devices isn’t optional – it’s essential for improving both user experience and conversion rates. Testing your forms on common breakpoints, such as 320–430px for smartphones and 768–1,024px for tablets, ensures they perform well in real-world scenarios[2]. Building on CSS customization techniques, you can use media queries, Flexbox, and CSS Grid to fine-tune your forms for responsiveness.
Using Media Queries
Media queries are a go-to solution for fixing layout issues on smaller screens. They allow you to apply specific CSS rules based on screen width, making it easy to stack multi-column fields vertically when space is limited. For instance, Gravity Forms’ Ready Classes like .gf_left_half and .gf_right_half create two-column layouts on desktops. You can use media queries to make these fields span the full width on smaller screens:
@media (max-width: 768px) { .gform_wrapper .gf_left_half, .gform_wrapper .gf_right_half, .gform_wrapper .gf_left_third, .gform_wrapper .gf_middle_third, .gform_wrapper .gf_right_third { float: none; width: 100%; margin-right: 0; } }
Adjust the breakpoint (e.g., 768px) to align with your theme’s mobile settings. Media queries can also enhance usability by increasing font sizes, padding, and button dimensions for smaller screens:
@media (max-width: 480px) { .gform_wrapper .gfield_label { font-size: 1rem; } .gform_wrapper .ginput_container input, .gform_wrapper .ginput_container select, .gform_wrapper .ginput_container textarea { padding: 0.75rem; } .gform_wrapper .gform_button { padding: 0.85rem 1.5rem; width: 100%; } }
These tweaks improve readability and make buttons easier to tap, ensuring a smoother experience for mobile users. For even more flexibility, consider using Flexbox or CSS Grid.
Flexbox and Grid for Responsive Layouts
Flexbox and CSS Grid provide advanced tools for managing layouts that adapt naturally across screen sizes. Flexbox is particularly useful for creating fluid column structures that automatically stack on narrower screens. Here’s an example of using Flexbox with media queries to adjust form fields:
@media (max-width: 768px) { .gform_wrapper .gfield.gf_left_half, .gform_wrapper .gfield.gf_right_half { flex: 1 1 100%; } }
This approach keeps fields like "First Name" and "Last Name" side by side on desktops but stacks them vertically on mobile, eliminating horizontal scrolling.
For more intricate layouts, such as three-column registration forms, CSS Grid offers precise control over column arrangements:
.gform_wrapper .gform_fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; } @media (max-width: 900px) { .gform_wrapper .gform_fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } } @media (max-width: 600px) { .gform_wrapper .gform_fields { grid-template-columns: 1fr; } }
To make specific fields, like "Address" or "Message", span the full width, use grid-column: 1 / -1;. CSS Grid is especially handy for maintaining precise control over layouts at different breakpoints while ensuring the design gracefully collapses into a single column on smaller screens.
Fixing Common CSS Problems
When styling Gravity Forms, it’s not uncommon to run into CSS conflicts or browser quirks. One of the biggest culprits? Theme conflicts. These account for about 40% of CSS-related support issues[6]. Popular themes like Divi and Avada often apply broad form resets, which can override Gravity Forms’ selectors like .gform_wrapper or .gfield. The result? Fonts, colors, and spacing may look completely off.
Resolving Theme Conflicts
If your custom CSS isn’t working as expected, the issue often boils down to CSS specificity. Your theme’s styles might be taking priority over your customizations. To identify the problem, use your browser’s developer tools to inspect the conflicting rules.
The fix? Increase your selector specificity. Instead of a general rule like .gfield label, add more context by including the form’s ID or the body tag. Here’s an example:
body #gform_wrapper_1 .gfield label { color: #333; font-size: 16px; }
For stubborn overrides, you can use !important, but apply it sparingly and only to specific properties, like this: background-color: #fff !important;. To make sure your custom styles persist through updates, add them to a child theme’s style.css file or the Additional CSS section in the WordPress Customizer. This ensures your styles load after the theme’s and remain intact.
For example, in a 2023 JetSloth tutorial, a user fixed radio button and checkbox styling issues in the Astra theme by overriding the theme’s generic input[type="radio"] selector with a more specific one:
.gfield-choice-input:checked + label:after { content: "\00D7"; border: 2px solid white; }
This tweak ensured smooth hover transitions across major browsers like Chrome, Firefox, and Safari, eliminating any visual glitches on the frontend[3].
Testing Across Browsers
Once you’ve resolved conflicts, it’s time to test your forms across multiple browsers. Different browsers can interpret CSS differently, which may lead to broken layouts, hidden buttons, or misaligned fields. Tools like BrowserStack allow you to test on real browsers, while Chrome DevTools‘ device emulation is great for quick mobile checks. Focus on current browsers like Chrome, Firefox, Safari, Edge, and mobile browsers such as Safari on iOS and Chrome on Android.
For older browsers like Internet Explorer 11, you may need to add fallbacks for modern CSS features. For instance, if a multi-column layout doesn’t work in IE11, you can use support detection to provide an alternative:
@supports not (display: flex) { .gform_wrapper { display: table; width: 100%; } .gfield { display: table-cell; } }
To avoid issues caused by cached CSS, test in incognito mode. You can also temporarily apply an outline to elements (e.g., .gform_wrapper * { outline: 1px solid red !important; }) to visualize their structure and pinpoint conflicts[5]. While !important can be a quick fix, prioritize improving specificity and take advantage of Gravity Forms’ CSS Ready Classes to streamline your styling process.
Conclusion and Next Steps
By now, you’ve got a solid understanding of Gravity Forms’ CSS structure and the tools it offers, giving you the ability to fine-tune your forms with precision. You’ve seen how to rely on built-in tools first, like the Appearance tab, Form Themes (such as Orbital), and CSS Ready Classes, which handle most layout tasks without the need for custom code. When custom CSS is required, you know exactly where to add it – whether it’s in the WordPress Customizer’s Additional CSS section or a child theme’s stylesheet – ensuring your changes remain safe during updates. Plus, you’ve learned how to create multi-column and responsive layouts using Ready Classes combined with Flexbox or Grid, along with media queries, to ensure your forms look great across devices like phones, tablets, and desktops. You’re also equipped with debugging strategies for resolving theme conflicts, specificity challenges, and cross-browser issues using developer tools.
Now it’s time to put this knowledge into action. Start by auditing your forms to identify areas for improvement, such as spacing, multi-column layouts, or responsiveness. For each form, explore what you can achieve using Appearance settings and Ready Classes before resorting to custom CSS for fine adjustments. Consider adding global form styles – like consistent fonts, button colors, and input borders – via the Customizer’s Additional CSS section to maintain a cohesive brand look across all your forms. Be sure to test your forms on popular U.S. devices and adjust details like padding, font sizes, and column stacking using media queries. Make a habit of reviewing your forms every quarter to catch and address recurring layout issues.
Here’s an example: An HVAC company in the U.S. saw a boost in booking completions by transforming a cramped single-column form into a more user-friendly, responsive, multi-column layout. They used Ready Classes to create two-column layouts for desktops, improved readability with custom CSS for line height and padding, and added mobile-first media queries to shift back to a single-column design on smaller screens. The result? A noticeable uptick in completed bookings – all accomplished using CSS and Gravity Forms’ built-in tools, without relying on additional plugins.
When you’re ready to take your skills further, check out WP Winners. This resource offers curated plugins, performance tips, and advanced tutorials tailored to the U.S. WordPress community. Whether you’re a beginner or a seasoned user, WP Winners can help you optimize not just Gravity Forms but also your site’s overall speed, SEO, and user experience. For those building forms as part of broader business websites, it’s an excellent place to discover high-quality add-ons and tools that integrate seamlessly with Gravity Forms and modern themes.
FAQs
How do I make Gravity Forms mobile-friendly using CSS?
To make Gravity Forms work well on mobile devices, you can use CSS media queries to tweak the layout for smaller screens. Here’s an example:
@media (max-width: 768px) { .gform_wrapper { width: 100%; padding: 10px; } .gfield_label { display: block; width: 100%; } .ginput_container { width: 100%; } }
This method adjusts the form elements to resize and stack vertically, making them easier to use and visually appealing on smaller screens. Be sure to test your forms on various devices and screen sizes to ensure they look and function as intended.
What are CSS Ready Classes in Gravity Forms, and how do they make customizing layouts easier?
CSS Ready Classes in Gravity Forms are pre-designed styling options that make it easy to customize form layouts without writing any CSS code. These classes allow you to tweak spacing, alignment, and layout directly within the form builder, saving time and simplifying the process for users of all skill levels.
With CSS Ready Classes, you can create forms that look polished and professional with minimal effort – whether you’re just starting out or have years of development experience.
How can I fix styling issues with Gravity Forms caused by my theme?
If your Gravity Forms styling clashes with your theme, you can resolve it by applying custom CSS with higher specificity or using !important to override conflicting styles. To ensure your changes persist through updates, either enqueue your custom CSS after the theme’s styles or work within a child theme.
Leverage your browser’s developer tools to inspect elements and identify the problematic styles. Once located, directly target those styles in your CSS. For more complex tweaks, you can use the hooks and filters offered by Gravity Forms to add custom classes or styles, giving you greater flexibility and control.


