nerdexam
CIW

1D0-720 · Question #103

Where is JavaScript code typically embedded in an HTML document?

The correct answer is B. Inside the <script> tag, either in the head or body sections. JavaScript is embedded using the <script> tag, which can be placed in either the <head> (for scripts that should load before the page renders) or the <body> (commonly at the bottom, to avoid blocking page rendering). Option A is wrong because <link> is for external stylesheets…

Client-Side Scripting and Media Queries

Question

Where is JavaScript code typically embedded in an HTML document?

Options

  • AWithin the <link> tag in the head section.
  • BInside the <script> tag, either in the head or body sections.
  • CDirectly within HTML tags as an attribute.
  • DInside the <style> tag in the body section.

How the community answered

(65 responses)
  • A
    2% (1)
  • B
    86% (56)
  • C
    8% (5)
  • D
    5% (3)

Explanation

JavaScript is embedded using the <script> tag, which can be placed in either the <head> (for scripts that should load before the page renders) or the <body> (commonly at the bottom, to avoid blocking page rendering). Option A is wrong because <link> is for external stylesheets, not scripts. Option C refers to inline event handlers like onclick="...", which is a limited and discouraged pattern - not where JS code is typically embedded. Option D is wrong because <style> contains CSS, not JavaScript.

Memory tip: Think "Script for Scripting" - the <script> tag is the dedicated home for JavaScript, just as <style> is for CSS and <link> is for linking external resources. Each tag has one job.

Topics

#JavaScript embedding#<script> tags#HTML structure#Client-side scripting

Community Discussion

4
Lena V.Lena V.Jun 7, 2026

B is correct. The script tag is the standard container for JavaScript in HTML, and you can place it in either the head or the body depending on when you need the code to run. Head placement runs before the page renders, body placement (usually just before the closing body tag) runs after the DOM is loaded, which avoids the classic "element not found" error beginners hit constantly. The other options describe real HTML elements but none of them execute JavaScript: link pulls in external resources like CSS, style holds CSS rules, and inline event attributes like onclick are a thing but that is not what "embedded JavaScript" means on this exam.

12
Dervla O.Dervla O.May 17, 2026

C is the distractor that'll burn you if you are moving too fast, because yes, you can write onclick or onmouseover attributes directly on HTML elements, and that is technically JavaScript sitting inside a tag. But the stem says "typically embedded," and the exam is testing the standard, canonical placement, which is the script element, and that element lives in either the head or the body depending on where the author wants execution to happen. D is a throwaway once you remember that style is for CSS, and A is the same trap in a different costume since link handles external stylesheets. Eliminate A and D immediately, slow down on C just long enough to notice that "typically" is doing real work in that stem, and you land on B with confidence.

3
Ingrid P.Ingrid P.May 21, 2026

Thought A was it, but script tag placement sealed B for me.

3
Mei-Ling H.Mei-Ling H.May 30, 2026

I almost picked C because I was thinking of inline event handlers like onclick="..." which you do write directly in HTML tags, but that is not where JavaScript code is "typically embedded" as a full block of code. The word "typically" is the key, and it points to B because the script tag is the standard way to embed actual JavaScript, whether you place it in the head or at the bottom of the body.

1
Full 1D0-720 Practice