-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
HTML: fix pre's incomplete description #37540
base: main
Are you sure you want to change the base?
Conversation
Preview URLs Flaws (23)URL:
External URLs (1)URL:
|
The **`<pre>`** [HTML](/en-US/docs/Web/HTML) element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or [monospaced](https://en.wikipedia.org/wiki/Monospaced_font) font. Whitespace inside this element is displayed as written. | ||
|
||
> [!NOTE] | ||
> A leading newline character immediately following the pre element start tag is stripped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here may have two conflicts:
- presented exactly as written? (no, the first blank line is stripped)
- Whitespace inside is displayed as written (no, same as above)
I have no idea how to improve the first sentence, and the following may fix the second one?
The **`<pre>`** [HTML](/en-US/docs/Web/HTML) element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or [monospaced](https://en.wikipedia.org/wiki/Monospaced_font) font. Whitespace inside this element is displayed as written. | |
> [!NOTE] | |
> A leading newline character immediately following the pre element start tag is stripped. | |
The **`<pre>`** [HTML](/en-US/docs/Web/HTML) element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or [monospaced](https://en.wikipedia.org/wiki/Monospaced_font) font. | |
> [!NOTE] | |
> A leading newline character immediately following the pre element start tag is stripped. Other whitespace inside this element is displayed as written. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great work, as always, @PassionPenguin!
So, for this one, I think your first conflict concern is OK — the wording provided is "represents preformatted text which is to be presented exactly as written". I think the stripping of the first blank line is intended to help with this — authors will appreciate being able to write their element content on separate lines to the opening and closing tags without having to worry about the leading newline character.
Also, note that the text following this line qualifies the exact behavior, so I think we are all good here. If you are still worried, you could maybe update "represents preformatted text which is to be presented exactly as written" to "represents preformatted text intended to be presented exactly as written", to signify that this is what the intent is, rather than the exact behavior?
For your second concern, I think this is valid — the whitespace line looks to be in conflict with your addition. To fix this, I would put the whitespace line into its own paragraph and combine it with your note, which I don't think needs to be a note.
So the second paragraph would read:
Whitespace inside this element is displayed as written, with one exception. If one or more leading newline characters are included immediately following the opening
<pre>
tag, the first newline character is stripped.
Let me know what you think. Thanks again!
Description
<pre>
will drop the first blank line (if exists) immediately following its start tag.Motivation
per @Josh-Cena's comment #37384 (comment)
Additional details
<pre>
's HTML documentation: https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element