This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21711 - Unclear statement regarding inclusion of newlines in <pre> and <textarea>
Summary: Unclear statement regarding inclusion of newlines in <pre> and <textarea>
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC All
: P3 normal
Target Milestone: ---
Assignee: Robin Berjon
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords: CR
Depends on:
Blocks:
 
Reported: 2013-04-16 08:57 UTC by Robin Berjon
Modified: 2014-01-16 15:10 UTC (History)
5 users (show)

See Also:


Attachments

Description Robin Berjon 2013-04-16 08:57:24 UTC
"A single newline may be placed immediately after the start tag of pre and textarea elements. This does not affect the processing of the element. The otherwise optional newline must be included if the element's contents themselves start with a newline (because otherwise the leading newline in the contents would be treated like the optional newline, and ignored)."

http://www.w3.org/html/wg/drafts/html/master/syntax.html#element-restrictions

If it's in the content then it must be included because if it weren't included it would be ignored? What is meant is that two newlines need be included.
Comment 1 Sam Ruby 2013-04-16 21:17:40 UTC
I believe I can shed some light on the history of this statement.  Obviously, reword it to taste.

When I was exploring the differences between XHTML and HTML, I noticed that while all newlines are significant in XHTML, the first newline of pre elements are ignored.  What you generally see in HTML is a <pre> on a separate line, one or more lines of text, and a </pre> again on a separate line.

In XHTML, this results in a blank line preceding the text.

I brought this up to Ian as something that wasn't (then) covered by the spec, and he added a paragraph (I haven't followed closely to see if it since changed).

Net effect: consuming applications of HTML must ignore the first character in the the <pre> and <textarea> elements if that character is a newline.

HTML producing applications can optionally add a newline in front of the value, but only are required to do so if the first character of that value is a newline.
Comment 2 Erika Doyle Navara 2013-07-20 00:08:27 UTC

EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are
satisfied with this response, please change the state of this bug to CLOSED. If
you have additional information and would like the Editor to reconsider, please
reopen this bug. If you would like to escalate the issue to the full HTML
Working Group, please add the TrackerRequest keyword to this bug, and suggest
title and text for the Tracker Issue; or you may create a Tracker Issue
yourself, if you are able to do so. For more details, see this document:

   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted

Change Description: Here's my attempt at rewording that final sentence:

A single newline may be placed immediately after the start tag of pre and textarea elements. This does not affect the processing of the element. If the element's contents are intended to start with a newline, two consecutive newlines thus need to be included by the author.

Master: https://github.com/w3c/html/commit/d601f6af9914aa0dadd3277c8771ed46995f61de

Cherry-pick to CR:
https://github.com/w3c/html/commit/8963a19d002ff90eba546c61f39a3d9ab4d07eda

Rationale: Rewording for to improve clarity for web authors for both HTML5 CR and 5.1 drafts. I didn't differentiate this HTML quirk from the same scenario in XHTML, as it seems sufficiently implied by this being situated in section 8 "The HTML Syntax" (as opposed to Section 9 "The XHTML Syntax").
Comment 3 github bugzilla bot 2014-01-16 15:10:16 UTC
Commit pushed to CR at https://github.com/w3c/html

https://github.com/w3c/html/commit/d601f6af9914aa0dadd3277c8771ed46995f61de
[Bug 21711] : Clarify statement regarding newlines in <pre> and <textarea.