I’m trying to embed a Google Map on my website to show my business location, but the code I grabbed from Google isn’t displaying correctly. Sometimes it shows a blank space or breaks my page layout. I need clear, step-by-step guidance on the correct embed code, where to paste it, and any settings I should check so the map shows up properly on both desktop and mobile.
This usually comes down to one of a few things: bad iframe code, CSS issues, or mixed content.
Here is a step by step that tends to work reliably.
- Grab the correct embed code
• Go to Google Maps
• Search your business
• Click “Share”
• Click “Embed a map”
• Choose size
• Copy the iframe code that starts with:
If the raw Google Maps iframe is breaking your layout, I’d actually step back and not rely on the default embed in some cases. @ombrasilente covered the usual iframe/CSS gotchas really well, so here are a few alternative / complementary tricks that often solve the stubborn cases:
1. Strip the iframe down to the bare minimum
Page builders and CMSes sometimes choke on all the extra attributes. Try the tiniest possible embed first:
<iframe
src='https://www.google.com/maps/embed?pb=YOUR_LONG_STRING'
width='600'
height='450'
style='border:0;'
></iframe>
No allowfullscreen, no loading, no referrerpolicy.
If this shows up, then start adding attributes one by one. When it breaks again, you know which one your builder/plugin doesn’t like.
2. Put it in a “safe” wrapper outside complex layout
If you have a gnarly layout (grids, sliders, accordions, weird themes), yank the map out of that context first.
Example:
<section id='location'>
<h2>Our Location</h2>
<div id='map-container'>
<!-- iframe here -->
</div>
</section>
Do not put it inside:
- Slider/Carousel
- Tab that is initially hidden with
display:none - Element that uses
height: 0tricks
Test it in a very “boring” spot in the page template. If it works there and not in your fancy section, the layout is the problem, not the map.
3. Use fixed height from CSS, not from the iframe
Sometimes global styles override the iframe height without you noticing. Try ignoring the height attribute in HTML:
<iframe
src='https://www.google.com/maps/embed?pb=YOUR_LONG_STRING'
class='business-map'
style='border:0; width:100%;'
></iframe>
Then in CSS:
.business-map {
height: 350px;
}
This avoids conflicts with themes that do stuff like iframe { height:auto; } or some “responsive iframe” hack that leaves your map at 0px tall.
4. Use a 16:9 responsive wrapper if the page is responsive
If you want it to scale nicely and not trash your layout:
<div class='map-responsive'>
<iframe
src='https://www.google.com/maps/embed?pb=YOUR_LONG_STRING'
style='border:0;'
allowfullscreen=''
loading='lazy'
></iframe>
</div>
.map-responsive {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
height: 0;
overflow: hidden;
}
.map-responsive iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
This usually survives most themes without wrecking the rest of the layout.
5. Check for script or sanitizer stripping the iframe
A lot of CMS setups quietly remove or “sanitize” iframe tags:
- In WordPress, some visual editors strip iframes unless you use the “Custom HTML” block.
- Some security plugins remove iframe content.
- Some newsletter builders or page builders convert
'into"or break the URL.
If you save the page, re-open the editor, and the iframe code looks different or is half-missing, that’s your culprit. In that case:
- Use a dedicated “Embed” or “HTML” block.
- Or configure your security plugin / editor to allow iframes from
https://www.google.com.
6. Avoid mixing it with JS map plugins
If you already have a map plugin or JS that targets iframe or .map classes, it can conflict with your embed:
- Some scripts dynamically resize iframes
- Others replace them or hide them in mobile view
Quick test: temporarily comment out all custom JS and any “map plugin” you have, then reload. If the map suddenly appears, you know some script is messing with it.
7. As a last resort, use a static image + link
If your theme/builder is just cursed and keeps mangling the iframe, do a low-tech version:
<a href='https://maps.google.com/?q=YOUR+BUSINESS+NAME' target='_blank'>
<img src='YOUR_MAP_SCREENSHOT.jpg' alt='Map to our business location'>
</a>
Clicking opens Google Maps in a new tab. Not interactive on-page, but it never breaks layouts, and users still find you.
If you post the exact iframe code and the HTML chunk around it, plus a screenshot of the blank area, it’d be easier to point at the specific culprit. Most of the time it’s not that the Google code is “wrong,” it’s that the theme, page builder, or some global CSS is quietly stabbing the iframe in the back.
Skip the map for a second and look at your page structure. When an embedded Google Map blows up the layout or shows as a blank, the root cause is often higher up the DOM, not the iframe itself.
A different angle from @sterrenkijker and @ombrasilente:
-
Validate the HTML around the iframe
Copy the whole section that contains the map into an HTML validator. A missing closing</div>or</section>before the iframe can cause everything after it to behave strangely. The Google code is usually fine; broken markup around it is not. -
Check your container’s computed styles, not just your CSS
Right click the blank area → Inspect → look at the<iframe>and its parent in DevTools. Under “Computed” check:displaywidthheightvisibilityopacity
If the iframe shows a tiny 0×0 size or inheritedvisibility:hidden, fix that at the container level instead of fighting the iframe.
-
Watch for transform / filter side effects
Parallax or fancy effects that usetransform,filter,clip-pathorbackface-visibilityon parents can cause odd rendering or make the iframe “disappear” visually. Temporarily disable those styles in DevTools and see if the map reappears. -
If you are using a builder, let the builder own the layout
Instead of dropping the raw iframe in between complex column widgets, put it in a very “plain” HTML block inside a single column, then let the builder handle spacing with its own margin/padding controls. Fighting the builder with extra wrappers can create exactly the layout break you are seeing. -
Consider a dedicated “Map section” pattern
Treat the map as its own section with:<section class='location-section'> <h2>Find our business location</h2> <div class='location-map-area'> <!-- Google Maps iframe --> </div> </section>Then style
.location-sectionand.location-map-areaso they play nicely with the rest of the design. This compartmentalizes problems instead of letting a misbehaving iframe interact with a complex grid or hero.
About the empty product title you mentioned, the main “pro” is that it keeps the embed minimal and focused, which usually improves readability and avoids conflicting scripts. The “con” is that a barebones approach means fewer built‑in layout safeguards, so you must be more careful with the surrounding containers and CSS.
Compared to what @sterrenkijker focuses on (clean embed code and basic CSS) and what @ombrasilente adds (responsive tricks and CMS quirks), this angle is more about structural hygiene and DevTools inspection. Combine all three approaches and you should be able to track down whether your issue is invalid markup, aggressive styling, or a page builder silently reshaping the iframe’s environment.