sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.44k stars 2.1k forks source link

html output W3C Validation issue ('Bad value “top” for attribute “rel” on element “link”) #3004

Closed hhsprings closed 7 years ago

hhsprings commented 7 years ago

themes/basic/layout.html has wrong link rel usage:

{%- block linktags %}
    {%- if hasdoc('about') %}
    <link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
    {%- endif %}
    {%- if hasdoc('genindex') %}
    <link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}" />
    {%- endif %}
    {%- if hasdoc('search') %}
    <link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}" />
    {%- endif %}
    {%- if hasdoc('copyright') %}
    <link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" />
    {%- endif %}
    <link rel="top" title="{{ docstitle|e }}" href="{{ pathto(master_doc) }}" />
    {%- if parents %}
    <link rel="up" title="{{ parents[-1].title|striptags|e }}" href="{{ parents[-1].link|e }}" />
    {%- endif %}
    {%- if next %}
    <link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}" />
    {%- endif %}
    {%- if prev %}
    <link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}" />
    {%- endif %}
{%- endblock %}

The value top and up is invalid for rel attribute. Please see W3CSchools, etc.

hhsprings commented 7 years ago

W3C Validation also reports:

info: 'Element “body” does not need a “role” attribute.'

Maybe it means verbose, so we can remove it simply, I think.

tk0miya commented 7 years ago

Memo: Indeed, top and up is no longer needed in HTML specification.

Tag HTML4 HTML5
author X O
index O X
search X O
copyright O O (basically uses license instead)
top X X
up X X
next O O
prev O O

refs:

tk0miya commented 7 years ago

About "document" role, WAI-ARIA says:

Authors SHOULD set the role of document on the element that encompasses the entire document. If the document role applies to the entire web page, authors SHOULD set the role of document on the root node for content, such as the body element in HTML or svg element in SVG.

https://www.w3.org/TR/wai-aria/roles#document

It seems setting the role to the body element is good way. So I will keep it.