Skip to content

Commit 80786eb

Browse files
committed
Add an 'unusual elements' appendix, to help with display:contents.
1 parent 73f8ffc commit 80786eb

1 file changed

Lines changed: 146 additions & 0 deletions

File tree

css-display/Overview.bs

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,152 @@ Appendix A: Glossary</h2>
912912

913913
See [[!CSS2]] <a href="https://www.w3.org/TR/CSS2/visuren.html">Chapter 9</a> for a fuller definition of these terms.
914914

915+
<h2 class="no-num non-normative" id="unbox">
916+
Appendix B: Effects of ''display: contents'' on Unusual Elements</h2>
917+
918+
Some elements aren't rendered purely by CSS box concepts;
919+
for example, replaced elements (such as <{img}>),
920+
many form controls (such as <{input}>),
921+
and SVG elements.
922+
923+
This appendix defines how they interact with ''display: contents''.
924+
925+
HTML Elements {#unbox-html}
926+
-----------------------------
927+
928+
: <{br}>
929+
: <{wbr}>
930+
::
931+
Issue: Ask the WG.
932+
Probably should just treat as ''display: none'',
933+
because they normally don't have contents,
934+
but theoretically they could be treated as "containing" a line feed or zwnj, respectively.
935+
936+
: <{button}>
937+
::
938+
Issue: Ask the WG.
939+
<{button}> is rendered via standard CSS,
940+
but it's often a form control,
941+
and looks identical to <code>&lt;input type=button></code>,
942+
which is *definitely* in the "semi-replaced" camp
943+
that gets ''display: none''.
944+
Which should it be consistent with?
945+
946+
: <{meter}>
947+
: <{progress}>
948+
::
949+
Issue: Ask the WG.
950+
These elements are probably replaced elements,
951+
but they do have reasonable contents inside of them.
952+
953+
: <{applet}>
954+
: <{canvas}>
955+
: <{embed}>
956+
: <{object}>
957+
::
958+
When acting as a [=replaced element=],
959+
''display: contents'' behaves as ''display: none''.
960+
961+
Issue: When non-replaced and displaying their contents,
962+
should we treat as a normal element
963+
and just strip the wrapper?
964+
965+
: <{audio}>
966+
: <{iframe}>
967+
: <{img}>
968+
: <{video}>
969+
::
970+
''display: contents'' behaves as ''display: none''.
971+
972+
: <{frame}>
973+
: <{frameset}>
974+
::
975+
''display: contents'' behaves as ''display: none''.
976+
977+
: <{input}>
978+
: <{textarea}>
979+
: <{select}>
980+
::
981+
''display: contents'' behaves as ''display: none''.
982+
983+
: <{legend}>
984+
::
985+
Per HTML, a <{legend}> with ''display: contents'' is not a [=rendered legend=],
986+
so it does not have magical display behavior.
987+
(Thus, it reacts to ''display: contents'' normally.)
988+
989+
: <{details}>
990+
: <{fieldset}>
991+
::
992+
These elements don't have any special behavior;
993+
''display: contents'' simply removes their [=principal box=],
994+
and their contents render as normal.
995+
996+
: any other element
997+
::
998+
Behaves as normal for ''display: contents''.
999+
1000+
SVG Elements {#unbox-svg}
1001+
---------------------------
1002+
1003+
<div class=issue>
1004+
Discussed in <a href="https://github.com/w3c/svgwg/issues/305">GitHub</a>.
1005+
1006+
SVG can be broken down into the following categories of elements:
1007+
1008+
: Root <{svg}>
1009+
::
1010+
Establishes the SVG formatting context.
1011+
Three options:
1012+
1013+
1. Treat as ''display: none''. (Contents can't usefully be hoisted.)
1014+
2. Strip the element,
1015+
but generate an anonymous SVG rendering context around contiguous SVG contents.
1016+
(In other words, internal SVG elements auto-wrap themselves,
1017+
like internal table elements do.)
1018+
3. Strip the element,
1019+
treat internal SVG elements similar to unknown HTML elements
1020+
(render as inline by default).
1021+
1022+
: Nested <{svg}>
1023+
: <{g}>
1024+
: <{use}> (treated as a Shadow DOM container)
1025+
::
1026+
Basically just a wrapping element,
1027+
could reasonably handle ''display: contents'' normally.
1028+
1029+
: Shape elements
1030+
::
1031+
Core rendering elements,
1032+
and usually empty.
1033+
(Contents, if present, are completely ignored.)
1034+
Could either strip normally and hoist contents,
1035+
or just treat as ''display: none''.
1036+
1037+
: <{text}>
1038+
Renders contained text,
1039+
but text doesn't display without a <{text}> wrapper.
1040+
Therefore, should probably ''display: none''.
1041+
1042+
: <{tspan}>
1043+
Like a <{span}>,
1044+
can probably usefully be stripped and have the contents hoisted.
1045+
1046+
: <{defs}>
1047+
:: Could theoretically be stripped and display its contents,
1048+
but that has negative usefulness,
1049+
so should probably just continue to not display contents.
1050+
(In other words, continue to ignore 'display' and suppress all boxes, as normal.)
1051+
1052+
: all other elements
1053+
::
1054+
Don't generate boxes anyway,
1055+
so they ignore 'display' entirely.
1056+
</div>
1057+
1058+
1059+
1060+
9151061
<h2 class=no-num id="acknowledgments">
9161062
Acknowledgments</h2>
9171063

0 commit comments

Comments
 (0)