Web Design

(Nancy Kaufman) #1

210


Embed JavaScript in HTML ......................................


2 Within the <head> section,
type <script.

1 Open an HTML document in
your editor.

Embed JavaScript in HTML


J


avaScript code can either be embedded directly within an HTML page or written in a separate text
file that is then linked to the page. You can embed JavaScript by adding a <style> tag to your

page. The tag is unique in HTML in that it is the only tag that can be legally placed in either the


or the of the document. The tag takes a required type attribute, which is always

set to a value of text/javascript. Be sure to remember the closing script tag because the


browser will fail to show anything on the page without it.


1


2

Free download pdf