Form fields not filling 100% width inside embedded form

I’m customizing a HubSpot form embedded on my website to match our brand identity. I was able to edit the spacing between fields, borders, colors, and button styles as needed.

However, the input fields are not filling 100% of the available form width. It seems there is an invisible inner container inside the form that prevents the fields from stretching fully and responding fluidly within the parent frame.

I also set all parent containers to width: 100% with box-sizing: border-box but the issue persists.

Has anyone found a solution to force the fields to fill 100% width inside the embedded form?

Thanks.
Here’s an image of how it looks now and an image of how it should look bellow.

Hi @luancampos ,
This is a common issue with embedded HubSpot forms. Since they’re loaded inside an iframe, the internal layout often uses default spacing and container widths that can be tricky to override. Even if you set all parent containers to 100% width, the form fields may still be restricted by HubSpot’s internal wrappers or max-width settings.

You can find more on this in these community threads:
https://community.hubspot.com/t5/CMS-Development/form-width-is-not-100-in-embedded-webpage/m-p/706417
https://community.hubspot.com/t5/Lead-Capture-Tools/Embedded-form-not-showing-full-width-inside-container/td-p/1125636

How to Fix:
You can override the default field width by adding custom CSS to your website (not inside the HubSpot form editor, but in your site’s stylesheet). For example:

/* Make the form and its fields fill 100% width */.hs-form,.hs-form fieldset,.hs-form .hs-form-field,.hs-form input,.hs-form textarea,.hs-form select {width: 100% !important;max-width: 100% !important;box-sizing: border-box;}/* Remove any max-width limits */.hs-form fieldset {max-width: none !important;}

A few things to double-check:

  • Make sure your custom CSS isn’t being overridden by HubSpot’s inline styles (use !important as needed).
  • Check that none of your site’s parent containers (divs, sections) have a fixed width or extra padding/margin that could restrict the form.
  • If you’re using a CMS builder or theme, ensure no parent element is limiting the width inside the iframe container.
  • Confirm you’ve removed any default max-width set on .hs-form, .hs-input, or .input classes.

Hope this helps!

@ArisudanTiwari please be sure to outline that your responses are AI generated.

This solution will not work given the information the original poster provided.

Hi @luancampos

You’re facing a common issue with HubSpot forms, especially when they’re added to websites outside of HubSpot. These forms come with built-in styles and container elements that can interfere with your own CSS settings, even if you’ve used width: 100% and box-sizing: border-box. The “invisible container” you’re seeing is probably a fieldset or another wrapper element with a max-width set by HubSpot.

Why This Happens:

  • HubSpot’s Built-In Styles: HubSpot automatically applies CSS to its forms. This often includes things like max-width on fieldset, .hs-form-field, or even the entire form, which can stop your fields from stretching to full width.
  • CSS Specificity: HubSpot’s styles might be more specific than yours, so even if you’re using width: 100%, their code takes priority.
  • Embedded as an iframe: If the form is embedded using an iframe (which HubSpot often does), your site’s CSS can’t directly affect the form’s styles inside that iframe.

How to Fix It:

To make your form fields fill the full width, you’ll need to target the right elements in your site’s CSS and use !important to override HubSpot’s styles. Also, make sure your CSS loads after HubSpot’s.

  • What to Target:

Use your browser’s “Inspect Element” tool to find the exact classes HubSpot uses. The most common ones are:

  • .hs-form — the whole form
  • fieldset — wraps groups of fields
  • .hs-form-field — individual field containers
  • .hs-input — input, select, and textarea elements
  • You can also target basic input types like: input[type=“text”], input[type=“email”], textarea, select

Sample CSS to Add to Your Site (not inside HubSpot):

/* General form elements */
.hs-form,
.hs-form fieldset,
.hs-form .hs-form-field,
.hs-form .hs-input,
.hs-form input[type="text"],
.hs-form input[type="email"],
.hs-form input[type="tel"],
.hs-form textarea,
.hs-form select {
 width: 100% !important;
 max-width: 100% !important; /* Crucial to override any max-width */
 box-sizing: border-box !important; /* Ensure consistent box model */
}

/* Remove any specific margin/padding that might cause shrinking */
.hs-form .hs-form-field {
 margin-right: 0 !important;
 margin-left: 0 !important;
 padding-right: 0 !important;
 padding-left: 0 !important;
}

/* For multi-column forms, you might need to adjust these */
.hs-form .form-columns-1 .hs-form-field {
 width: 100% !important;
}

.hs-form .form-columns-2 .hs-form-field {
 /* Adjust for two columns, accounting for spacing */
 width: calc(50% - /* some margin/gap */) !important;
 float: left; /* Or use flexbox on the parent if preferred */
}

A Few Things to Keep in Mind:

  • Be Specific with Your CSS: The more detailed your CSS selectors are (for example, using .hs-form .hs-input instead of just input), the better chance they have of overriding HubSpot’s built-in styles.
  • Using !important: Normally, it’s best to avoid using !important because it can make your code harder to manage later. But in this case—since you’re working with HubSpot’s strong, injected styles—it’s often necessary to get your changes to stick.
  • Where You Put Your CSS Matters: Make sure your custom CSS loads after HubSpot’s styles. This usually means placing your CSS in your main theme file (like style.css) or in a custom CSS section of your website builder.
  1. Turn Off HubSpot’s Default Styles (Advanced Option): If you want full control over how your form looks, HubSpot gives you the option to disable its built-in styles. You can do this by adding css: “” to the form’s embed code. This lets you style everything yourself using your own website’s CSS.
    Here’s what the original embed code might look like before making the change:
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
 hbspt.forms.create({
 region: "na1",
 portalId: "YOUR_PORTAL_ID",
 formId: "YOUR_FORM_ID"
 });
</script>

Modified embed code to disable styling:

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
 hbspt.forms.create({
 region: "na1",
 portalId: "YOUR_PORTAL_ID",
 formId: "YOUR_FORM_ID",
 css: "" // Add this line
 });
</script>

If you go this route, you’ll need to handle all the styling yourself—from basic fonts and spacing to mobile responsiveness. It can take quite a bit of work, so this option is best if you have a very custom design that really doesn’t work well with HubSpot’s default styles.

  1. Check the Parent Containers:

Even if your form fields are set to 100% width, they might still be getting restricted by their parent containers—like <div>, <section>, or other wrappers around the form. These might have fixed max-width, padding, or margin that’s stopping the form from stretching fully. Use your browser’s Inspect tool to look through the layout and spot any styles that might be limiting the width.

  1. Check HubSpot Form Settings:

Don’t forget to review the form settings directly in HubSpot. Even if you’re using custom CSS, HubSpot’s form builder has some basic layout options—like field width and column layout—that can help. Go to the “Style & Preview” tab in the form editor and make sure the form field width is set to Full Width (or something similar), if that option is available. It’s a good starting point before adding more custom code.

How to Debug the Issue:

  1. Inspect the Form Field: Open your website in a browser, right-click on one of the form fields, and choose “Inspect”. This will open the browser’s developer tools.
  2. Check the CSS Rules: In the Styles panel, look at the CSS being applied to the input field and its parent elements (like .hs-form-field or fieldset). Focus on any width or max-width properties—especially ones added by HubSpot.
  3. Find Conflicting Styles: If your custom styles are being ignored, you’ll likely see them crossed out (with a strikethrough). This means HubSpot’s styles are taking priority due to higher specificity.
  4. Test Fixes in Dev Tools: Try adding width: 100% !important; and max-width: 100% !important; directly in the developer tools to see if that solves the problem.
  5. Apply Fixes to Your CSS: Once you figure out which elements need adjustments, add those styles to your website’s main CSS file so the fix is permanent.

By targeting the right elements and using !important where necessary, you should be able to make your form fields stretch to fit the full width as expected.

You cannot directly style or manipulate the contents of an iframe with CSS or JS if it’s from a different origin (the embedded HubSpot form in your website is from a different origin, look up CORS policy).
You can control the parent node in your website that the HubSpot form is embedded in though. For example, call the parent wrapper with a CSS class then give it negative margins like this:

​.hubspot-iframe-wrapper{
 margin-left: -40px;
 margin-right: -40px;
}

If anyone is having this issue with forms on HubSpot CMS you can add this CSS to your page or theme CSS styles.

<style>
.hsfc-Step__Content {
 padding: 0;
}
</style>