[wp-trac] [WordPress Trac] #65253: Superfluous whitespace in comment cookie consent markup
WordPress Trac
noreply at wordpress.org
Sat May 16 13:27:55 UTC 2026
#65253: Superfluous whitespace in comment cookie consent markup
--------------------------+-----------------------------
Reporter: zodiac1978 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 5.3
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I always wondered why the checkboxes in my blog are not correctly aligned.
Today I looked at it and found a superfluous space in the markup.
The code can be seen here:
https://github.com/WordPress/WordPress/blob/fe7b727fe416a39bef68df0aeaf2a143c5fd3763
/wp-includes/comment-template.php#L2576-L2595
This is the relevant part:
{{{
<p class="comment-form-cookies-consent">%s %s</p>
}}}
The first placeholder is containing the input field and the second
placeholder is the label.
In the source code of the page it looks like this:
{{{
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent"
type="checkbox" value="yes" /> <label for="wp-comment-cookies-consent">
}}}
As you can see, there is a space between the two HTML tags.
Typically this margin is better controlled by CSS, like this:
{{{
.comment-form #wp-comment-cookies-consent {
margin: 0 10px 0 0;
}
}}}
Every default theme has this margin right next to the input field:
https://github.com/search?q=repo%3AWordPress%2FWordPress+%23wp-comment-
cookies-consent+language%3ACSS+%22margin%3A+0+10px+0+0%3B%22&type=code
The space is adding an extra margin. And there is no easy way to fix this,
as this space is only seen in the source code.
I've checked the themes in the official directory and only 679 themes are
using this CSS ID:
https://veloria.dev/search/2d4217d1-3ca1-4bca-8557-771f355df322
Some of those themes even don't add a margin to the right and some are
just adding 5px, to match the 10px (if you add the space), so maybe this
is intentional to have space between Label and text even if there is no
CSS for this in the theme.
In the first iteration of this feature there was no space between this
tags:
#43436
The space was introduced with this changeset:
https://core.trac.wordpress.org/changeset/46088
The suggested fix would be to remove the space:
{{{
<p class="comment-form-cookies-consent">%s%s</p>
}}}
But this would need a dev note for theme devs, who maybe worked around
this or haven't added any margin at all.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/65253>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list