Steps to reproduce: echo "<head><script>();</script></head>" | tidy -q --tidy-mark 0 Test results: <!DOCTYPE html> <html> <head> <script> (); </script> <title></title> </head> <body> </body> </html> The problem doesn’t occur when the script is in body instead of in head: echo "<body><script>();</script></body>" | tidy -q --tidy-mark 0 Test results: <!DOCTYPE html> <html> <head> <title></title> </head> <body> <script> (); </script> </body> </html> Also, doesn’t happen with a meta element in head instead of script. Version: HTML Tidy for Linux version 5.6.0 Possibly related issues: #760