Skip to content

Provide a guarantee of the order in which CSS is included in html output #8634

@akhmerov

Description

@akhmerov

Is your feature request related to a problem? Please describe.

CSS uses cascading order where the latest stylesheet included takes precedence over earlier ones. Therefore in order for the extension authors and documentation authors to be able to control the appearance of the output, in particular if they want to override the style, a guarantee of the ordering seems necessary. However right now sphinx does not seem to provide any promise of the order in which CSS files are inserted. I am aware of at least two occasions when an extension adding a stylesheet after the user-provided custom CSS has resulted in an issue: jupyter/jupyter-sphinx#149 and executablebooks/sphinx-tabs#15 .

Describe the solution you'd like

Add an explicit documentation and a guarantee of the order in which the CSS is included in the resulting pages.

In the current implementation it could be as simple as promising that the CSS is included in the following order:

  • Theme
  • Extensions in the order in which they are listed
  • User-provided custom css

I think this should also be taken into consideration when implementing per-page html assets (see #6241, #8631)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions