To apply both an external script and an inline script in one page, what should she do?

Advance your skills with the uCertify CIW – Advanced HTML5 and CSS3 Specialist Test. Study with flashcards and multiple-choice questions, complete with hints and explanations to enhance your learning. Prepare effectively and ace your exam!

Multiple Choice

To apply both an external script and an inline script in one page, what should she do?

Explanation:
When you want both an external script and some inline code on the same page, you should use two separate script elements. One script tag should load the external file with the src attribute, and another script tag should contain the inline code without a src. A script tag that has a src attribute does not execute its inline content, so you can’t put both inside one tag. Using two tags lets you control the order: place the external script first so its functions are available to the inline code that follows. The defer attribute only affects external scripts and won’t help combine inline code with an external file in a single tag, so it’s not a solution here.

When you want both an external script and some inline code on the same page, you should use two separate script elements. One script tag should load the external file with the src attribute, and another script tag should contain the inline code without a src. A script tag that has a src attribute does not execute its inline content, so you can’t put both inside one tag. Using two tags lets you control the order: place the external script first so its functions are available to the inline code that follows. The defer attribute only affects external scripts and won’t help combine inline code with an external file in a single tag, so it’s not a solution here.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy