-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconsider FAQ: <di>, <div> or <li> wrapping <dt> and <dd> #1937
Comments
Wrapping in How about allowing |
Indeed, |
|
I'm 👍 to DIV. I also really like LI if it auto-closes better and gets some UA styling, but that's a lot of effort. |
|
I have been wanting this for a long time. Kudos to y'all for coming up with something that might fly. |
Summoning @sideshowbarker I'm thinking we make the content model as strict and simple as possible: either No change to the parser, rendering, or other UA requirements; this should only affect document conformance. |
Spec-wise, it seems there is no way around a wrapping element with mandatory end tag. The deciding question probably is which one (new or reused) provides the best backwards compatibility:
Semantically, all variants can be argued for well enough. |
I think we shouldn't mint a new element, as I said, it doesn't interact well with omitting end tags of And That leaves 3. I can't think of any practical problems with it. As far as accessibility tools go, I've quickly tested VoiceOver with Safari and ChromeVox with Chrome (both on Mac OS X), and there was no difference for 3. Since the stated problem is about styling, I think getting no difference in accessibility tools should be a goal. With More testing in other screen reader/browser/platform combinations is welcome, but so far I think |
As far as any proposal for changing the But I think the using-an-existing-element option that would carry the least risk of that problem is the Certainly it’s practical to implement the checking for that in the validator So I like the As far as the option of instead minting a new element, from a conformance-checker POV: while it doesn’t carry the risk that I think a repurpose-an-existing-element option does of possibly causing authors to miss genuine mistakes the checker would otherwise help them catch, IMHO it’s not the right option in this case—for the same reasons @zcorpan gives but also because:
|
This only changes the content model and the rules for determining what a dl element represents. Fixes #1937.
I've prepared a PR for spec change at #1945 |
I'd prefer |
On 21 October 2016 at 11:20, Simon Pieters notifications@github.com wrote:
the element is 'semantically neutral' as far as AT are concerned.
they are ignored, except in some cases where they are descendants of ARIA composite user interface widgets. These roles typically act as containers that manage other, contained widgets. Regards SteveF |
Thanks @stevefaulkner! |
Having thought about the options presented here, I think going with I've no doubt that you can make this work on the implementation side, but I think it would be very confusing to authors. If I can use The Furthermore we'd be establishing a precedent of using As for “implementors have shown relatively little interest in it”--adding a new tag that has no particular behavior is not an interesting problem implementation-wise, and Hixie was adamant about not adding a definition-group element to the spec, so this is hardly indicative of anything. |
Thank you for bringing a concrete downside of
I have not seen examples of confusion due to the above though. Then on the argument that this would set a "bad" precedent and future cases will also reuse
That's it, as far as I can tell. For other elements, say |
I do think that |
The element here should be meaningless. The semantics are identical with or without the wrapper element. The PR has an algorithm for doing semantic analysis of a |
Personally, I don't see the point of adding more meaningless elements. If styling/selecting is an issue this should be resolved by (improvements to) css selectors. If it makes sense to add a meaningful element to group def-titles and def-descs, and it does, and by doing so you make it easier to select things for styling, then all the better. |
It appears that you are missing context @inoas; I suggest you read the original post again and follow the links. |
For completeness, styling is not the only benefit from allowing a wrapper element; also:
|
I read the opening post again, including the discussion in the Rationale. After reading I still think that:
I read about the drawbacks of self-closing
Wouldn't this...: <dl>
<div>
<dt>a
<dd>b
</div>
<div>
<dt>c
<dd>d
</div>
</dl> Result into that as well?: <dl>
<div>
<dt>a</dt>
<dd>b
<div>
<dt>c</dt>
<dd>d</dd>
</div>
</dd>
</div>
</dl> But my stance is that some things just take time and once vendors implement semantic grouping support, then after some time you can start using it. |
That has been WHATWG's stance as well, until it became clear that CSS will not support this, as stated in OP:
.
No, it does not, see this link from @Crissov's comment above .
It doesn't have to be that way, though; |
Well if it is backwards compatible anyway I personally don't see a reason not to allow |
Naive question: why would |
I think it does, but OK. If we did change |
@zcorpan The name-value groups themselves are not and should not be different. It the question of whether the wrapper element is used appropriately or not. |
Then there is no change in semantics.
It is up to the spec itself to define what is appropriate use of an element. The appropriate use of the wrapper element in |
Using
I meant to say that it is the question of whether the wrapper element is used semantically or not. |
You have still failed to explain what the difference would be. There are at least 4 problems that would need to changes in all browsers before |
@zcorpan As some other commenters and I had reiterated multiple times, the difference would be our HTML becomes more semantic by using I agree that we are not going to get any further if people in authority have no desire to address the 4 problems. |
It appears that you are using a different definition of semantics than the HTML spec (or indeed, any HTML spec) has ever done. Your definition of semantics appears to have something to do with tag names, but that's not what semantics are about. I'd suggest carefully reconsidering and re-reading the appropriate specification sections. If you disagree with the meaning of semantics in HTML, that's fine, but that's an argument for not using HTML and instead using a different language; we're not going to change the meaning of semantics in HTML according to your notion. |
@domenic Thanks for your concern. I'm not using a different definition of semantics than the HTML spec. And I know semantics is not necessarily linked with tag names. |
There are still two issues being discussed here IMHO, one is perfectly summed up by @Hixie's comment:
That hits the nail on any Historically attributes (like microdata) where always a 2nd choice, if at all, to reinforce semantics, while tags where the first choice. And that's a good paradigm. Historically since HTML 4+ CSS was meant to do the styling not HTML. The current state of the 95% web is horrible (inefficient non-semantic soup) precisely because things like flex-box and display: table took so long to agree upon and press forward and meanwhile people re-implemented their old table-layouts as div-class-soup (also called Bootstrap or Foundation). Thus the whole paragraphes about itemprops and itemscopes makes me quite sad when I see how it is glued to a div when instead it could have been a semantic grouping element that made sense even IF the UA or user would not understand the microdata. The other is related and has to do with semantically grouping elements. A single def-title can be described by multiple def-descriptions and/or multiple def-titles can be described by a single def-description. AFAIR currently the spec creates new dom nodes for every Sure headers and paragraphs also bundle up as semantic blocks that belong to each other by the spec. Still andA new This whole issue here tries to fix this the semantic auto-glueing that is implied in def-lists. But instead of fixing it at the root, it simply patches in something that "works already" despite that it is bad design. Putting The Spec should:
But obviously you are not going to change anything unless it fits the needs and desires of the current implementors of browser engines and/or their companies. I can see the practicability, doesn't mean that it is always the best long term thing to do. |
@zcorpan: I think a new I don't see why this requires parser changes either; just change the "Tag omission in text/html" text in the spec. See https://html.spec.whatwg.org/multipage/semantics.html#the-dt-element. Right now, the aforementioned text for Do likewise for The only browser implementation change needed is a UA stylesheet update to make it a block-level element as was the case with the |
Saying that the end tag is required in this context is not so helpful because tools probably exist that assume it is optional anywhere, and will just strip them out. If the end tag is optional sometimes and sometimes not, I don't think it would be less confusing overall. Some developers are likely to run into accidentally violating the rule and end up with a weird DOM and be confused. |
I'd suggest that hypothetical tools that perform tag-stripping should not be considered relevant as these are (A) hypothetical and (B) have no bearing on the long-term use of HTML, which is more important.
In contexts where optional end tags are always used, this is a moot point. I think tag omission should treated as a legacy issue rather than a feature that other features must yield to. In this case, a long-term feature is being created and it seems to be designed with the principle that tag omissibility is something that should be preserved.
In an HTML spec amended as proposed, what you'd be describing is a syntax error. It's no different than an author ending up with an unexpected DOM because they forgot to terminate a |
Tag omission is a crucial part of writing modern, clean HTML; several major style guides mandate it. It's one of HTML's greatest features in my opinion. Some may dislike it, but we certainly have no intention of treating it as a legacy issue. |
Maybe a consensus is needed from the community on tag omission. While some may like it and think it makes HTML clean, I personally think it causes inconsistency among content-wrapping tags and makes HTML less careful. I myself always avoid using tag omission. |
https://github.com/html5lib/html5lib-python dl.html <dl><dgroup><dt>hello</dt><dd>hello</dd></dgroup></dl> test-serialize.py import html5lib
f = open("dl.html")
tree = html5lib.parse(f)
str = html5lib.serialize(tree)
print str
|
It seems pretty clear to me that there is no consensus on optional end tags in the community. As @domenic said, there are style guides that recommend it (e.g., this one), and just in this thread we see people with differing opinions. Some people like it, some people don't. But consensus is not necessary to make a decision in the WHATWG. See the FAQ and an old post by Hixie. |
@zcorpan Thanks. I see. @patrickdark and all other who are interested in a new |
It's an improvement that we're not dealing in hypothetical tools. I see no reason why the tool can't be fixed, however. It also seems that the tool is in a beta state—which suggests a good time for a fix—and two of its three libraries are dead, so I'm not sure how relevant it is. Authors who have deployed this tool can use existing workarounds for lack of a description list grouping element until the tool is updated. (I'm not familiar with Python, but I'm guessing the fix would be relatively trivial too given that this tool seems to be based on an XML tree generator where tags are mandatory.)
Tag omission is an optional—not crucial—part of HTML. I write code in XHTML where this shortcut is simply disallowed and haven't missed it. Tag omission does allow one to write less verbose code, but this comes at the expense of code clarity. That we're even having this discussion about tag omission producing unpredictable DOMs using conventional source code structures seems to be proof of that. (It also seems to be proof that the parsing design is fundamentally flawed and moreso if tag omission is a feature to be added to future elements, but since parsing changes are off the table...)
You've pointed out a singular example that "recommends" tag omission after said style guide has declared that part of itself "optional". Further, it explicitly acknowledges that its optional recommendation is not part orthodox Web development instruction. Further, this singular guide doesn't appear to be attributed to any individuals or organizations—despite its implied association with Google—and is written in a custom XML syntax instead of HTML, so I'm not sure why it should be held as a credible authority for determining the future evolution of HTML.
All the more reason to do the right thing and not shoehorn the But alas, I guess we're going to be stuck writing non-straight-forward |
I’d like to add my voice to the discussion, although I might not be adding anything new. I know others have already expressed similar views, and I also know other others will disagree. But I want to cast my vote. I like the idea of repurposing/extending the “div is non-semantic” is not good enoughI understand the reasoning behind choosing First of all, the implicit grouping model goes out the window when we are now using an explicit element to group Now, the first point is moot, because more importantly, there is indeed a reason for needing a wrapping element in the first place: to add semantics. I’m not talking about styling issues, which can & should be solved with CSS; I’m talking about markup issues, such as how to mark up <h1>Important Dates:</h1>
<dl>
<li itemscope="" itemtype="http://schema.org/Event">
<dt><time datetime="2015-10-12" itemprop="startDate">Oct 12, 2015</time></dt>
<dd itemprop="name">Topic Due</dd>
</li>
<li itemscope="" itemtype="http://schema.org/Event">
<dt><time datetime="2015-11-12" itemprop="startDate">Nov 12, 2015</time></dt>
<dd itemprop="name">Draft Due</dd>
</li>
<li itemscope="" itemtype="http://schema.org/Event">
<dt><time datetime="2015-12-12" itemprop="startDate">Dec 12, 2015</time></dt>
<dd itemprop="name">Final Paper Due</dd>
</li>
</dl> In this example, one could argue that Side note: I know this isn’t really a convincing point, but I like to think of introducing a new element is cumbersomeI agree with the many posts in this discussion about the costs of adding a new element, be it If Incidentally, how fitting would it be for an |
Mixing is invalid.
You can do this with
|
I understand your reasons for not wanting I think it comes across as near-sighted to make a decision based on the way things currently are and how today’s tools work at this time, in fear that a change will cause one of them to break. I get the whole pave the cowpaths concept but allowing |
If you get all implementations to change such that the problems with #1937 (comment) demonstrates what the parsing problem is. |
Now this is just logical but still bad: #2007 (comment) - why would divs work here but not there? I can see the point. But the solution is to not have a div tag but be patient with browser vendors to implement a or tag. There is no need to hurry on this one and it can easily take 3 years and almost no harm will be done because the addition of dt/dd grouping is really a minor feature (compared to such things as http2, webasm, fetch or push/preload etc.) |
This only changes the content model and the rules for determining what a dl element represents. Fixes whatwg#1937.
Explicitly grouping
dt
anddd
together has been proposed so often that it’s featured in the Rationale and has been in the FAQ since 2008, getting further explained in 2010.There will be no CSS pseudo-element
::wrap
in the forseeable future, see w3c/csswg-drafts#588. I believe it’s therefore worth to reevaluate the use cases and review the FAQ entry.Current state
The parsing rules for
dl
are quite clear, but even if browsers implemented them perfectly, there’d still be no way to take advantage of the structure in CSS.di
WrapperThis has also been called
dli
. It has all the problems of any new element type, and some more.li
WrapperIt has all the problems of using existing elements in places where they were not supposed to occur previously, which can be quite unexpected.
dt
/dd
inli
It may be worth exploring whether ditching
dl
has better backwards compatibility than changing it.Generic
list
elementThe text was updated successfully, but these errors were encountered: