homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

background color for an iframe

5+ Year Member

Msg#: 10903 posted 11:11 am on Aug 27, 2005 (gmt 0)

i've read a few messages on this topic but havent been able to get a working solution. how can we change the background color of an iframe from its default white to black(or any other color) using an inline style tag within the iframe tag.
would be glad if anyone can help.



5+ Year Member

Msg#: 10903 posted 2:18 pm on Aug 27, 2005 (gmt 0)

Well whatever page you are feeding through the iframe is where you are going to need change the background properties. unless you have like a default value set in your .css for HTML {} or BODY {} though I'm not even sure of the reliability of that.

Basically whatever page you're loading into the iframe will control the background color.

P.S. - iframes suck in soooooo many ways ;)


Aapo Laitinen

5+ Year Member

Msg#: 10903 posted 4:49 pm on Aug 27, 2005 (gmt 0)

Changing the background color of the
iframe element won't have any effect unless the body element of the framed page has its background property set to transparent.

In some situations JavaScript can be used to alter the background color or to set it to transparent. It would help if you described what page you are framing and why.


5+ Year Member

Msg#: 10903 posted 6:52 am on Aug 28, 2005 (gmt 0)

i'm using iframes because frames divide the entire browser. thereby changing the look of the page esp when resolutions are different. i tried using allowtransperancy=true within the iframe tag but its not working. I'm using CSS for the body tag. will try again by setting the background property within the body tag of the framed page to transperant. thanks for the replies.


5+ Year Member

Msg#: 10903 posted 3:44 am on Aug 31, 2005 (gmt 0)

have you considered using a <div> layer to do the same thing? i have only used iframes a couple times but those were strictly because i needed to have dynamic content load on a static page while still being able to control certain physical aspects of the dynamic page such as width and height...

you have access to all the scrollbar features etc... that an iframe has except you can not refresh/reload layers independently of the rest of the site, therefore you can not target a page to load to the div... you can however, use javascript to turn visibility on or off very easily...



5+ Year Member

Msg#: 10903 posted 4:02 pm on Aug 31, 2005 (gmt 0)

i've found a solution. Thanks for all the help.


WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 10903 posted 11:28 am on Sep 10, 2005 (gmt 0)

Won't you please share your discovery, for the benefit of all who read this thread?


10+ Year Member

Msg#: 10903 posted 4:54 pm on Oct 3, 2005 (gmt 0)

Hi I had a look at this, and thanks to Aapo Laitinen
who mentioned to set the background to transparent on the body of the document contained IN the iframe, I found a solution.

Just setting the background-color doesn't seem to work, but creating a small gif of the appropriate color and setting the background-image: (whatevercolourwant.gif) will do the trick.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved