CSS / HTML5 is equivalent to iframe marginheight and marginwidth

I am making a site layout for a company that uses IDevAdManager to rotate ads on its site. Unfortunately, I am not a very expert in this field, so I cannot give much about this. What can I say for sure, although due to the nature of the generator, the source inside the frames generated by it is not edited by me.

Now here is my problem.

I am trying to make my new website compatible with HTML5, but I have an interesting problem.

When it comes to adding frames from the ad rotator, it generates all the old, discounted tags used by previous HTML implementations.

Obviously, most of them can be removed using CSS. All except, however, the marginheight and marginwidth attributes.

Here I get to my problem. There seems to be no CSS equivalent of the width of the marginheight or margin, and there is no way to access the source in an iframe. However, eliminating them prevents proper alignment of the internal content.

I hope to find a solution that is valid HTML5 and solves my problem.

Currently there is such an option? Or will I have to use outdated tags until a solution is developed?

+6
source share
3 answers

This is actually the right question. Unfortunately, it turns out that marginheight, marginwidth and frameborder are properties of the iframe element itself, and not the style style of the element, see http://www.w3schools.com/jsref/prop_frame_marginheight.asp

So, for example, you can do this in JavaScript:

document.getElementById("SomeIframe").marginheight = "0"; 

but you cannot do it

 document.getElementById("SomeIframe").style.marginheight = "0"; 

and setting the field has no effect (i.e. you still get the default margin in the iframe element):

 document.getElementById("SomeIframe").style.margin = "0"; 

So the answer to cbright6062 is that it is not possible to set marginheight, marginwidth and frameborder properties for iframes in the stylesheet.

+5
source

To be true HTML5, the document inside the iframe must have the correct style, not the iframe itself. I do not know what adManager is, but it depends on how the iframe is created.

If it is dynamic and the same, you can enter it

 document.getElementById("SomeIframe").contentDocument; 

and set the style field to 0.

 let myFrameBody = document.getElementById("SomeIframe").contentDocument.querySelector('body'); myFrameBody.style.margin = 0; 

If this is not the same as the document owner has to install it himself, and this is never a bad idea, and also with regard to HTML4.1 this will be considered valid.

0
source

Bit was late for the party, but using css to install the iframe add-on, you need to do the trick.

-one
source

Source: https://habr.com/ru/post/1396542/


All Articles