Skip to content

Docs HTML: Remove self-closing tags #132220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged

Docs HTML: Remove self-closing tags #132220

merged 2 commits into from
Apr 7, 2025

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Apr 7, 2025

Self-closing tags (<tag />) do not exist in HTML.

If a trailing / (slash) character is present in the start tag of an HTML element, HTML parsers ignore that slash character. This is especially important to remember for elements such as <script> or <ul> that do require a closing tag. In these cases, adding a trailing slash in the start tag does not close the element. Instead, the trailing slash is ignored, and the element is treated as open until an explicit closing tag is encountered or until the parser implicitly closes the element based on the HTML structure and parsing rules. For example, in the case of <div/>Some text, browsers interpret this as <div>Some text</div>, treating the slash as ignored and considering the div element to encapsulate the text that follows.

https://developer.mozilla.org/en-US/docs/Glossary/Void_element#self-closing_tags

Let's omit them: they're ignored, could be misleading (give the false impression they do something when they do not) and are ugly (IMO).


📚 Documentation preview 📚: https://cpython-previews--132220.org.readthedocs.build/

@picnixz
Copy link
Member

picnixz commented Apr 7, 2025

I think we have self-closing tags in Sphinx' writers so we should also fix this upstream.

@AA-Turner AA-Turner requested a review from a team as a code owner April 7, 2025 15:14
@hugovk hugovk merged commit ce72457 into python:main Apr 7, 2025
24 checks passed
@hugovk hugovk deleted the deslash branch April 7, 2025 15:21
@miss-islington-app
Copy link

Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @hugovk, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ce724571b35f4e79fff1c862fcd9afa4c26b605f 3.13

@miss-islington-app
Copy link

Sorry, @hugovk, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ce724571b35f4e79fff1c862fcd9afa4c26b605f 3.12

hugovk added a commit to hugovk/cpython that referenced this pull request Apr 7, 2025
(cherry picked from commit ce72457)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Apr 7, 2025

GH-132228 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Apr 7, 2025
hugovk added a commit to hugovk/cpython that referenced this pull request Apr 7, 2025
(cherry picked from commit ce72457)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Apr 7, 2025

GH-132229 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Apr 7, 2025
AA-Turner added a commit that referenced this pull request Apr 7, 2025
AA-Turner added a commit that referenced this pull request Apr 7, 2025
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants