7

I'm making a flask application and just stuffed it all into a Visual Studio pyproj file and am just reviewing all the edit suggestions the IDE is proposing. One of them is where I put the <script> tag in the html. The code worked as the browser is very forgiving I know with html, but what exactly did I unwittingly violate?

script inside html tags

1
  • 2
    include it inside body tag. Commented Mar 29, 2017 at 18:55

2 Answers 2

13

It should be inside body tag. So move one line up.

Sign up to request clarification or add additional context in comments.

2 Comments

Right, I did that to fix it once I realized my typo, and others in my various template files, but I'm more curious what the constraints are surrounding where you can place script tags and stuff. Still pretty noob to web development coming from desktop development.
@jxramos Basically to either <head> or <body>. In <head> - must be direct child (not nested inside any other tag), while in <body> you can place inside other <div> or directly to <body>. You can inspect websites to see how other uses it.
1

Looks like it's a simple matter of malformatted html, by standard/design I'm guessing. According to https://www.w3schools.com/js/js_whereto.asp ...

JavaScript in <head> or <body>

You can place any number of scripts in an HTML document.

Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.