WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 4 years ago

#11554 closed defect (bug) (fixed)

Calendar generated by WordPress is invalid HTML5

Reported by: avcascade Owned by: ryan
Milestone: 3.2 Priority: normal
Severity: minor Version: 2.9
Component: Validation Keywords: has-patch
Focuses: Cc:

Description

While building an HTML5 theme for WordPress (I don't use XHTML, this is why) I discovered that the calendar generated by WordPress' general-template is not valid HTML5.

Two attributes are causing problems: summary (which is obsolete) and abbr, which seems redundant since title contains the same information.

Removing the summary and abbr attributes from general-template causes a WordPress blog with an HTML5 theme to properly validate using the conformance checker. Since the summary and abbr attributes do not appear necessary for the display of the calendar, it seems like removing them would make the core leaner and meaner.

Line with summary:

echo '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">

There are several lines with abbr, like:

echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";

Attachments (4)

ValidationErrorsWPCalendar.html (12.0 KB) - added by avcascade 6 years ago.
11554.patch (2.0 KB) - added by iammattthomas 5 years ago.
Removes the summary attribute from the calendar table element. Removes the abbr attribute from the calendar th and td elements. Calendar output validates as HTML5.
11554.2.patch (635 bytes) - added by ocean90 4 years ago.
Screenshot.png (197.2 KB) - added by studionashvegas 4 years ago.
Ran a source dump of a clean install with one widget through the validator - checks clean.

Download all attachments as: .zip

Change History (18)

comment:1 @dd326 years ago

  • Keywords dev-feedback added; Calendar removed

WordPress itself does not output HTML5, instead, All functions will generally return HTML4/XHTML strings.

Theme authors may replace core strings via filters and/or registering their own widgets if WordPress's output doesnt conform to their Doctype specifications.

I'm setting this a dev-feedback, with the question of: What Doctypes does WordPress currently support, and what should it support?

Given that the attributes there at present are virtually useless to most people, i see no reason to not remove them, however, Future output may not conform to HTML5 spec either.

comment:2 @hakre6 years ago

WordPress does support any doctype. It can be configured. Mainly this is HTML and XHTML but this is configure-able.

HTML5 still is a draft, it makes no sense to validate against it right now.

But in any case, the reported redundant information should be removed. I would favor for the title attribute.

comment:3 @hakre6 years ago

  • Keywords needs-patch added; dev-feedback removed

Some wise words: The referenced resource - which is a must read for any webdev - suggests to stick with HTML 4.01. Why not build a theme based on that standard. I would like to see WordPress to at least validate against that standard (plus ARIA maybe).

comment:4 @hakre6 years ago

  • Milestone changed from Unassigned to 3.0

@iammattthomas5 years ago

Removes the summary attribute from the calendar table element. Removes the abbr attribute from the calendar th and td elements. Calendar output validates as HTML5.

comment:5 @iammattthomas5 years ago

  • Keywords has-patch added; needs-patch removed

comment:6 @ryan5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12943]) Make calendar valid HTML 5. Props iammattthomas. fixes #11554

comment:7 @anmari4 years ago

  • Component changed from Template to Widgets
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 2.9 to 3.2

Line 1149 of general-template.php in 3.2 "bleeding edge" just updated is still generating html warnings - Patch not applied?

<table id="wp-calendar" summary="Calendar"

The summary attribute is obsolete. Consider describing the structure of complex tables in <caption> or in a paragraph and pointing to the paragraph using the aria-describedby attribute.

Last edited 4 years ago by anmari (previous) (diff)

comment:8 @ocean904 years ago

  • Component changed from Widgets to Template
  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 3.0 to 3.2
  • Version changed from 3.2 to 2.9

Interesting, it was reverted with r13048 by mistake.

@ocean904 years ago

comment:9 @ocean904 years ago

  • Keywords has-patch added; needs-patch removed

@studionashvegas4 years ago

Ran a source dump of a clean install with one widget through the validator - checks clean.

comment:10 @studionashvegas4 years ago

  • Resolution set to worksforme
  • Status changed from reopened to closed
  • Version changed from 2.9 to 3.2

Patch applied, source ran through HTML5Validator (http://html5.validator.nu/) with clean validation.

comment:11 @nacin4 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from 3.2 to 2.9

comment:12 @ramoonus4 years ago

  • Component changed from Template to Charset

doesn`t this belong to validation?

comment:13 @ramoonus4 years ago

  • Component changed from Charset to Validation

comment:14 @ryan4 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from reopened to closed

In [18120]:

Remove summary attribute. Props ocean90. fixes #11554

Note: See TracTickets for help on using tickets.