Title: Concepts of Algorithmic Thinking HTML and Javascript: Working together to add interactivity and resp
1Concepts of Algorithmic ThinkingHTML and
JavascriptWorking together to add interactivity
and responsiveness to a static HTML page
- D.A. Clements
- UW Information Schoolischool.washington.edu
2HTML Basics
3Basic HTML Structure
- All HTML files use the same structure
lthtmlgt ltheadgt lttitlegtName of Page Goes
Here lt/titlegt Heading content goes here
lt/headgt ltbodygt Body content goes here
lt/bodygt lt/htmlgt
4Basic HTML Structure
- lthtmlgt, ltheadgt, lttitlegt, and ltbodygt tags, and
their closing tags are required.
lthtmlgt ltheadgt lttitlegtName of Page Goes
Here lt/titlegt Heading content goes here
lt/headgt ltbodygt Body content goes here
lt/bodygt lt/htmlgt
5Basic HTML Structure
- Tags are pairedopening and closing tags
lthtmlgt ltheadgt lttitlegtName of Page Goes
Here lt/titlegt Heading content goes here
lt/headgt ltbodygt Body content goes here
lt/bodygt lt/htmlgt
6Basic HTML Structure
- Other tags nest inside the lthtmlgt tags
lthtmlgt ltheadgt lttitlegtName of Page Goes
Here lt/titlegt Heading content goes here
lt/headgt ltbodygt Body content goes here
lt/bodygt lt/htmlgt
7Basic HTML Structure
- An HTML file is divided into head and body
sections.
lthtmlgt ltheadgt lttitlegtName of Page Goes
Here lt/titlegt Heading content goes here
lt/headgt ltbodygt Body content goes here
lt/bodygt lt/htmlgt
8Basic HTML Structure
- The ltheadgt contains metadata.
lthtmlgt ltheadgt lttitlegtName of Page Goes
Here lt/titlegt Heading content goes here
lt/headgt ltbodygt Body content goes here
lt/bodygt lt/htmlgt
Metadata
9Basic HTML Structure
- The body contains the page contenteverything
that shows on the Web page.
lthtmlgt ltheadgt lttitlegtName of Page Goes
Here lt/titlegt Heading content goes here
lt/headgt ltbodygt Body content goes here
lt/bodygt lt/htmlgt
Content
10Implementing javascript
- How JavaScript and HTML work together
11JavaScripts and HTML
- Types of JavaScripts
- Body scripts
- Header scripts
- External scripts
12Body Script
lthtmlgt ltheadgt lttitlegtName of Pagelt/titlegt
lt/headgt ltbodygt ltscript typetext/javascript
gt //JavaScript goes here lt/scriptgt
lt/bodygt lt/htmlgt
13Body Script
lthtmlgt ltheadgt lttitlegtName of Pagelt/titlegt
lt/headgt ltbodygt ltscript typetext/javascript
gt //JavaScript goes here lt/scriptgt
lt/bodygt lt/htmlgt
14Header Script
lthtmlgt ltheadgt lttitlegtName of Pagelt/titlegt
ltscript typetext/javascript
//JavaScript goes here lt/scriptgt lt/headgt
ltbodygt Body content goes here
lt/bodygt lt/htmlgt
15External Script
- Linked in the ltheadgt
- src gives pathname
lthtmlgt ltheadgt lttitlegtName of Pagelt/titlegt
ltscript typetext/javascript
srcbasic.jsgtlt/scriptgt lt/headgt ltbodygt
Body content goes here lt/bodygt lt/htmlgt
16External JavaScript
- Make changes to scripts in one place
- Reusable
- Can be linked to any page, every page in a site,
or many sites
17End papers