Why is HTML5 not validating but not providing an alternative?

I don't understand HTML 5. The validator says:

The marginwidth attribute for the iframe element is deprecated. Use CSS instead. The marginheight attribute for the iframe is deprecated. Use CSS instead.

But according to this accepted answer :

there is no way to set the marginheight, marginwidth and frameborder iframe properties in the stylesheet.

Why are they asking me to do something that is simply impossible?

Either supply a thing that works in the spec or come up with a viable alternative. They seem to disapprove of something and their alternative doesn't work.

What am I missing here?

+3


source to share


2 answers


The HTML5 specification describes how the marginheight and marginwidth attributes work. It says:

For each property in the following table, given a body element, the first attribute that contains a map for the pixel length property on the body is the element. If none of the attributes of a property are found, or if the value of the found attribute cannot be successfully parsed, then it is expected that the default value of 8px will be used for that property instead.

Property        Source
'margin-top'    body element marginheight attribute
                The body element container frame element marginheight attribute
                body element topmargin attribute
'margin-right'  body element marginwidth attribute
                The body element container frame element marginwidth attribute
                body element rightmargin attribute
'margin-bottom' body element marginheight attribute
                The body element container frame element marginheight attribute
                body element bottommargin attribute
'margin-left'   body element marginwidth attribute
                The body element container frame element marginwidth attribute
                body element leftmargin attribute

      

If the body element of the Document view is a nested view context, and the view context container of that nested view context is a frame or iframe element, then the frame element of the body element's container is a frame or iframe element. Otherwise not a container frame element.

So, to achieve the same effect, you must set the CSS field values ​​on the body element of the containing page, not the CSS field values ​​of the iframe element.



The spec then goes on to explain why marginwidth and marginheight may not (or even should) be supported in browsers:

Warning! The above requirements imply that the page can change the fields of another page (including from another source) using, for example, an iframe. This is a potential security risk, as in some cases it could allow an attack to create a situation in which the page will not display as expected, possibly for phishing or misleading the user.

+3


source


I would say that you should always be a little skeptical about information about the W3C.

If you want to push it down to literals - they are correct - there is no direct equivalent in CSS , however CSS does provide existing alternatives (so none of the properties are still supported, they are redundant).

marginheight

- top and bottom margin, so just use margin-top

and margin-bottom

... same is true for marginwidth

, use margin-left

and margin-right

(or put all together in margin

)

As for frameborder

- just set the border

iFrame to CSS.



<iframe marginheight='10' marginwidth=20' frameborder='0'>

Can be done in HTML / CSS with:

<iframe>

iframe{
  margin:10px 20px;
  border:none;
}

      

0


source







All Articles