Why self-closing `<script />` tags don't work in HTML?
Hi everyone! I'm a beginner frontend developer and I ran into a very strange problem that cost me a lot of time.\n\nI'm writing a simple HTML page and want to include an external JavaScript file. It seems simple, but the code doesn't work. Here's my HTML:\n\n```html\n\n\n\n \n Test \n \n\n\n
`, `
Hello, world!
\n \n\n```\n\nI expected some output from the `app.js` script to appear on the page, but nothing happens. There are no errors in the browser console, but the script doesn't seem to load. However, if I use `` with a closing tag, everything works perfectly.\n\nI'm used to the fact that in HTML5 many tags can be self-closing: ``, `
No answers yet.
Log in to leave an answer
Blogs
How to Write a REST API in C++ in 30 Minutes: A Step-by-Step Guide