Skip to content

Commit 931288b

Browse files
authored
Update responsive-iframes-explainer.md
Fix typos
1 parent 72911ee commit 931288b

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

css-sizing-4/responsive-iframes-explainer.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Problem description
44

5-
[url](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe) are very useful for sandboxing web content into different documents. The options currently available are:
5+
[Iframes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe) are very useful for sandboxing web content into different documents. The options currently available are:
66
1. A [same-origin](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) iframe, which provides full style &
77
layout isolation, and by-default script isolation. This prevents the parent and child documents from accidentally interfering with each other.
88
2. A cross-origin iframe, which additionally provides robust security and privacy against untrusted embedders or embedees.
@@ -14,17 +14,17 @@ This is a problem:
1414
* From a user's perspective, iframe scrollbars are a worse UX in cases where the iframe contents are important to them and can fit reasonably in the visible viewport without these additional scrollbars.
1515
* From a developer's perspective, they are forced to use non-trivial script to communicate natural dimensions across frames in order to help the user have better UX without scrollbars.
1616

17-
Embedded SVG documents already support responsive layout. *Responsive iframes* add responsive layout to iframes, as long as the embedding and embedded document both opt into do so, thus providing support for responsive layout without losing any of the advantages of iframes in (1) and (2) above.
17+
Embedded SVG documents (in `<object>`/`<embed>`) already support responsive layout. *Responsive iframes* adds responsive layout to iframes, as long as the embedding and embedded document both opt in to doing so, thus providing support for responsive layout without losing any of the advantages of iframes in (1) and (2) above.
1818

1919
## Use cases
2020

2121
Use cases include:
22-
* 3P comment widgets [example](https://github.com/whatwg/html/issues/555#issuecomment-177836009)
23-
* Embedding self-contained worked examples in teaching UI (https://browser.engineering/layout.html)
22+
* 3P comment widgets ([example](https://github.com/whatwg/html/issues/555#issuecomment-177836009))
23+
* Embedding self-contained worked examples in teaching UI ([example](https://browser.engineering/layout.html))
2424

2525
In general, there is a lot of demand for this feature, as evidenced by:
2626
* [Stack overflow](https://stackoverflow.com/search?q=resize+iframe)
27-
* Many comments and positive reactions on the [issue proposing the feature for HTML](https://github.com/whatwg/html/issues/555), and [the same for CSS](https://github.com/w3c/csswg-drafts/issues/1771).
27+
* Many comments and positive reactions on the [issue proposing the feature for HTML](https://github.com/whatwg/html/issues/555), and [the same for CSS](https://github.com/w3c/csswg-drafts/issues/1771)
2828
* Existence of multiple polyfills
2929

3030
## Solution
@@ -37,18 +37,19 @@ The double opt-in preserves:
3737
* Backward compatibility for existing content
3838
* Privacy and security guarantees of cross-origin content
3939

40-
The "one-shot" sizing to natural dimensions avoids:
40+
The "one-shot" (only at `load` time) sizing to natural dimensions avoids:
4141
* Performance issues and CLS due to changing iframe sizing (To further mitigatge performance risks, limitations on levels of `<iframe>` nesting may be imposed.)
4242
* Potential infinite layout loops
4343

4444
## Example:
4545

46-
The following example wil display an iframe of content `width `300px` (the default) and height `1000px` (the height of the `<div>`),
47-
plus a 1px border.
46+
The following example wil display an iframe of content width `300px` (the default) and height `1000px` (the height of the `<div>`),
47+
plus a `1px` border. Without this feature, the iframe would have been `150px` (the defaut) tall with a vertical scrollbar.
4848

4949
Embedding document:
5050

5151
```html
52+
<!doctype HTML>
5253
<style>
5354
iframe {
5455
contain-intrinsic-size: from-element;
@@ -60,16 +61,17 @@ Embedding document:
6061

6162
`my-iframe.html`:
6263
```html
64+
<!doctype HTML>
6365
<style>
6466
* { margin: 0; }
6567
</style>
66-
<meta name="responsive-embedded-sizing">
67-
<div style="height: 100px">
68+
<meta name="responsive-embedded-sizing"></meta>
69+
<div style="height: 100px"></div>
6870
```
6971

7072
## Future extensions
7173

72-
A JavaScript API could be added in the future that would allow embedded documents to request relayout in their embedding document context.
74+
A JavaScript API could be added in the future that would allow embedded documents to request relayout in their embedding document context. This would allow dynamically generated iframe documents to update at times other than `load`.
7375

7476
## Privacy and security
7577

0 commit comments

Comments
 (0)