Skip to content
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

x/net: html.Parse does not parse self closing token correctly #26566

npchp110 opened this issue Jul 24, 2018 · 1 comment


None yet
3 participants
Copy link

commented Jul 24, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?


What did you do?

package main

import (


func main() {
	raw := `<video src="a.mp4"/><p>xx</p>`
	root, _ := html.Parse(strings.NewReader(raw))
	html.Render(os.Stdout, root)

What did you expect to see?

`<p>xx</p>' parsed as child of body:
<html><head></head><body><video src="a.mp4"></video><p>xx</p></body></html>

What did you see instead?

'<p>xx</p>' parsed as child of video:
<html><head></head><body><video src="a.mp4"><p>xx</p></video></body></html>

@gopherbot gopherbot added this to the Unreleased milestone Jul 24, 2018


This comment has been minimized.

Copy link

commented Jul 24, 2018

I think parser behaves correctly here. Your input is non-conformant — spec tells that for video element "Neither tag is omissible" — so your input is parsed as if video element holds <p> which is what you see in rendering.

This program prints parsed tree nesting:


Note that browsers also parse such input in a similar fashion — here's what tree produced Safari:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.