Iframe is not the correct size

AI-generated summary

jacob_kahn reported that an embedded iframe was appearing too small in a Discourse topic and asked for help. simon explained that iframe dimensions must be set using width and height attributes directly on the iframe tag — not via CSS style — because Discourse strips style attributes during post processing. Simon provided a working YouTube iframe example and suggested using width="600" height="400" as a starting point, noting that 600px is likely the maximum allowed width. jacob_kahn confirmed the fix worked perfectly and thanked Simon, wishing happy holidays.

hey everyone!

I can’t get my iframe that I’m trying to embed in a topic correct. look how small it is! does anyone know how to fix this?

thanks in advance!

You need to set the iframe’s width and height as absolute values. Also, the width and height need to be set as attributes of the iframe, and not in a style attribute (Discourse will remove the style attribute when it processes the post.)

Here’s an example copied from a Youtube iframe that shows how it’s done:

<iframe width="560" height="315" src="https://www.youtube.com/embed/r-i6XpcL1Fs" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

I think the max width you can use in a Discourse post is 600. It should be fine to use the iframe code from your screenshot, but just add width="600" height="400" to it, after the opening iframe tag. You can try different values for the width and height to see what works.

@simon thank you so much! that worked perfectly! happy holidays!