HTML
Lab
Meet the (old) booksite
- In a browser, go to
headfirstlabs.com/books/hfhtml
.
-
Download and extract the code for chapter 1.
Investigate with Windows Explorer.
- Find the index.html file in the Starbuzz Coffee subdirectory.
- Open this file with a browser.
- View the source for this web page. Hold down the Ctrl key and type the letter u.
Create your first web page
- Open Windows Explorer. Unhide file extensions (see step 3, page 15).
- Open Notepad. Save As hello.html.
- Create an html element:
- Create the opening tag. Type: < h t m l > .
- Leave some blank lines.
- Create the closing tag. Type: < / h t m l > .
- Between these two tags, create head and body elements:
- Type: < h e a d > , leave a blank line, type: < / h e a d > .
- Type: < b o d y > , leave a blank line, type: < / b o d y > .
-
Inside the body element, create a paragraph element.
Type: < p > H e l l o W o r l d < / p > .
-
Inside the head element, create a title element.
Type: < t i t l e > M y F i r s t W e b P a g e < / t i t l e > .
- Save your file.
- Open your file with Internet Explorer.
- Open your file with Firefox.
Add a JavaScript event handler
- Edit hello.html with Notepad.
-
Inside the head element,
after the title element,
create a script element:
- Create the opening tag. Type: < s c r i p t > .
- Leave a blank line.
- Create the closing tag. Type: < / s c r i p t > .
-
Between these two tags, type:
o n l o a d = f u n c t i o n ( ) { a l e r t ( " H i " ) ; }
.
- Save your file.
- Open your file with Internet Explorer.
- Open your file with Firefox.
Always turn off your computer and screen before leaving the room.