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
Consider removing language suggesting <tr>
is a valid child of <table>
#33505
Comments
The parser behaviour you refer to is not fixing invalid HTML markup; it is merely normalizing already-valid markup. At least according to the
If the markup is valid, why shouldn't it be used? |
As explained in the above issue, I'd hardly call it "valid" -- it will never exist in that form once being passed through the parser. It's a recoverable and documented (though not in MDN) error state. It's as valid as nesting buttons or anchors, putting flow content into a paragraph, etc., which is to say not at all. For a real-world example, I recently had to help a user debug their CSS which had the following selector: |
MDN clearly says that nesting If putting Having said that, I agree that regardless of whether it is valid, it is confusing and should not be recommended. MDN should still mention it, just as MDN mentions deprecated attributes, but should also explain why it should not be used. |
If the input does not match the parser output, the input is invalid. It's not complicated. The HTML parsers are incredibly capable bits of software that can recover from an ungodly number of errors, but knowingly passing input that it'll have to correct is not ever "valid". This isn't normalization, this is fixing incorrect markup. To call it "normalization" implies it's optional, or can exist in a denormalized state, which it isn't and cannot.
MDN does not document parser behavior in any other situation so I fail to see why it should here. |
What's valid is determined by the spec: https://html.spec.whatwg.org/multipage/tables.html#the-tr-element, which says:
What's valid is also what's considered valid by the W3C validator, which does consider a document like this to be valid: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>example page</title>
</head>
<body>
<table>
<tr>
<td>a</td>
</tr>
</table>
</body>
</html> |
Reality often disagrees with spec docs, I wouldn't put too much weight behind one, and in reality, But at this point, I'm tapping out. A conversation on the realities of adherence to spec docs in regards to the web platform isn't a good use of my time. As the title indicates, I think MDN should consider removing information that is not entirely accurate and leading users down incorrect paths. |
That said, I do think it's worth describing the parser's behavior, to help out people with this issue:
...as @BrianJDrake says here:
|
MDN URL
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr
What specific section or headline is this issue about?
Usage Notes
What information was incorrect, unhelpful, or incomplete?
What did you expect to see?
I suppose not this?
Do you have any supporting links, references, or citations?
While
<tr>
is "allowed" as a child of<table>
, all parsers will wrap it in a<tbody>
, turning this:into this:
Saying
<tr>
"may be placed as a direct child" I think is a bit questionable. Even if parsers will fix this, it shouldn't be done.Do you have anything more you want to share?
No response
The text was updated successfully, but these errors were encountered: