Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have to apply CSS to an <iframe> present in my HTML page using jQuery. The CSS must only be applied to that <iframe> and not the other parts of the HTML. Can anyone help me to do it using jQuery?
<iframe>
The best way to do it using just css is to access the iFrame with an id, like this:
$('#iframe-unique-name').children().css('background-color', 'red');
This would set the background color of the elements contained within the iframe to red, for example.
Add a comment
If the iframe's URL (src attribute) don't violate the same domain policy, you should be able to...
iframe
src
$('iframe').contents().find('body').css({ fontSize: '130%' });
And if it doesn't, it will be on your domain. Can you just put the CSS there in the iframe's source?
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.