HTML Css02
HTML Css02
<p>The moon is
earth.</p>
LINE BREAKS
<p><strong>Beware</strong> pickpockets
operate in this area.</p>
<a href="http://www.imdb.com">IMDB</a>
WRITING LINKS
<a href="http://www.imdb.com">IMDB</a>
WRITING LINKS
<a href="http://www.imdb.com">IMDB</a>
HTML
<a href="http://www.empireonline.com">
Empire</a>
RESULT
LINKING TO OTHER PAGES
ON THE SAME SITE
HTML
<a href=”index.html”>Home</a>
<a href=”about.html”>About</a>
<a href=”movies.html”>Movies</a>
<a href=”contact.html”>Contact</a>
RESULT
RELATIVE examplearts
URLS index.html
movies
cinema
index.html
listings.html
reviews.html
dvd
index.html
listings.html
reviews.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
RELATIVE examplearts
URLS index.html
movies
cinema
SAME index.html
reviews.html listings.html
reviews.html
dvd
index.html
listings.html
reviews.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
RELATIVE examplearts
URLS index.html
movies
cinema
index.html
listings.html
reviews.html
CHILD dvd
music/index.html index.html
listings.html
reviews.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
RELATIVE examplearts
URLS index.html
movies
cinema
index.html
listings.html
reviews.html
dvd
index.html
listings.html
PARENT reviews.html
../index.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
RELATIVE examplearts
URLS index.html
movies
cinema
index.html
listings.html
reviews.html
dvd
index.html
listings.html
reviews.html
music
index.html
GRANDCHILD
movies/dvd/index.html listings.html
reviews.html
theater
index.html
listings.html
reviews.html
RELATIVE examplearts
URLS index.html
movies
cinema
index.html
listings.html
reviews.html
dvd
index.html
listings.html
reviews.html
music
index.html
listings.html
reviews.html
GRANDPARENT theater
../../index.html index.html
listings.html
reviews.html
EMAIL LINKS
HTML
HTML
<h1 id="top">
Film-Making Terms</h1>
<a href="#arc-shot">
Arc shot</a><br />
<a href="#interlude">
Interlude</a><br />
<a href="#prologue">
Prologue</a><br />
…
<h2 id="prologue">
Prologue</h2>
LINKING TO A SPECIFIC PART OF
THE SAME PAGE
<h1 id="top">
Film-Making Terms</h2>
<a href="#arc-shot">
Arc shot</a><br />
<a href="#interlude">
Interlude</a><br />
<a href="#prologue">
Prologue</a><br />
…
<h2 id="prologue">
<h2
Prologue</h2>
id="prologue">
Prologue</h2>
<a href="#top">Top</a>
LINKING TO A SPECIFIC PART OF
THE SAME PAGE
<h1 id="top">
Film-Making Terms</h1>
Terms</h2>
<a href="#arc-shot">
Arc shot</a><br />
<a href="#interlude">
Interlude</a><br />
<a href="#prologue">
Prologue</a><br />
<h2 id="prologue">
Prologue</h2>
<a href="#top">Top</a>
LINKING TO A SPECIFIC PART OF
THE SAME PAGE
<h1 id="top">
Film-Making Terms</h1>
Terms</h2>
<a href="#arc-shot">
Arc shot</a><br />
<a href="#interlude">
Interlude</a><br />
<a href="#prologue">
Prologue</a><br />
…
<h2 id="prologue">
<h2
Prologue</h2>
id="prologue">
Prologue</h2>
<a href="#top">Top</a>
LINKING TO A SPECIFIC PART OF
THE SAME PAGE
<h1 id="top">
Film-Making Terms</h1>
Terms</h2>
<a href="#arc-shot">
Arc shot</a><br />
<a href="#interlude">
Interlude</a><br />
<a href="#prologue">
Prologue</a><br />
…
<h2 id="prologue">
<h2
Prologue</h2>
id="prologue">
Prologue</h2>
<a href="#top">Top</a>
CHOOSING IMAGES
FOR YOUR SITE
HTML
<img src="images/quokka.jpg"
alt="A family of quokka"
title="The quokka is an Australian
marsupial that is similar in
size to the domestic cat" />
RESULT
RESULT
This is using Chrome, but this can be done in any desktop browser.
Chrome on smartphone: need to use URL view-source:http://whatever.
Can carefully edit URL with pencil that shows up with tap on URL.
HEIGHT & WIDTH OF IMAGES
HTML
<img src="images/quokka.jpg"
alt="A family of quokka"
title="The quokka is an Australian
marsupial that is similar in
size to the domestic cat"
width="600"
height="450" />
RESULT
Resizing RESULT
• The browser receives the HTML, parses the <img> URL, and
issues another GET request for the image data (no user
involvement here)
From https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
WHERE TO PLACE IMAGES
IN YOUR CODE
http://htmlandcssbook.com/code-
samples/chapter-05/where-to-place-images.html
“OLD CODE” RESULT
• HTML:
<body>
<img src="images/quokka.jpg" alt="Quokka (Setonix brachyurus)" />
</body>
• Note how it stays the same size while you resize the
page. It shows in 600x450 screen pixels.
• On my laptop, 600 px width = 50% of screen width
• Right-click on image in Chrome, Inspect, to see its
dimensions.
Pixels
• Each digital image has a grid of pixels, written as width x height, for
example 600x450
<figure>
<img src="images/otters.gif"
alt="Photograph of two sea otters
floating in the water" />
<br />
<figcaption>Sea otters hold hands when
they sleep so that they don’t
drift away from each other.
</figcaption>
</figure>
HTML5: FIGURE &
FIGURE CAPTION
<figure>
<img src="images/otters.gif"
alt="Photograph of two sea otters
floating in the water" />
<br />
<figcaption>Sea otters hold hands when
they sleep so that they don’t
drift away from each other.
</figcaption>
</figure>
HTML5: FIGURE &
FIGURE CAPTION
<figure>
<img src="images/otters.gif"
alt="Photograph of two sea otters
floating in the water" />
<br />
<figcaption>Sea otters hold hands when
they sleep so that they don’t
drift away from each other.
</figcaption>
</figure>
RESULT
online
WHAT'S A TABLE?
BASIC TABLE STRUCTURE
<table> HTML
<tr>
<td>15</td>
<td>15</td>
<td>30</td>
</tr>
<tr>
<td>45</td>
<td>60</td>
<td>90</td>
</tr>
</table>
RESULT
TABLE HEADINGS
<table> HTML
<tr>
<th></th>
<th scope="col">Saturday</th>
<th scope="col">Sunday</th>
</tr>
<tr>
<th scope="row">Tickets sold</th>
<td>120</td>
<td>135</td>
</tr>
</table>
RESULT
SPANNING COLUMNS
... HTML
<tr>
<th>Monday</th>
<td colspan="2">Geography</td>
<td>Math</td>
<td>Art</td>
</tr>
...
RESULT
SPANNING ROWS
... HTML
<tr>
<th>6pm - 7pm</th>
<td rowspan="2">Movie</td>
<td>Comedy</td>
<td>News</td>
</tr>
<tr>
<th>7pm - 8pm</th>
<td>Sport</td>
<td>Current Affairs</td>
</tr>
RESULT
WHY FORMS?
FORM CONTROLS
HOW FORMS WORK
username=Ivy
NAME & VALUE PAIRS
NAME
username=Ivy
NAME & VALUE PAIRS
NAME
username=Ivy
VALUE
Name-value pairs sent to server
• HTTP GET: in URL query string
POST /webapp/program
… headers
… encoded name-value pairs
HTML
<form
action="http://example.com/join.php"
method="get">
</form>
TEXT INPUT
HTML
<form
action="http://example.com/join.php">
</form>
RESULT
PASSWORD
HTML
<p>Username:
<input type="text" name="username"
size="15" maxlength="30" />
</p>
<p>Password:
<input type="password" name="password"
size="15" maxlength="30" />
</p>
RESULT
TEXTAREA
HTML
<textarea name="comments"
cols="20" rows="4">
Enter your comments...
<textarea/>
RESULT
RADIO BUTTON
</p>
RESULT
CHECKBOX
HTML
<p>Your favorite music service:<br />
<input type="checkbox" name="service"
value="iTunes"
checked="checked" /> iTunes
HTML
<select name="devices">
<option value="iPod"
selected="selected">iPod</option>
<option value="radio">Radio</option>
<option value="PC">Computer</option>
</select>
RESULT
MULTIPLE SELECT BOX, select with
additional attribute (red)
<select name="devices" size="4“ HTML
multiple="multiple">
<option value="guitar"
selected="selected">Guitar</option>
<option value="drums">Drums</option>
<option value="keys"
selected="selected">Keyboard</option>
<option value="bass">Bass</option>
</select>
RESULT
FILE INPUT BOX: we won’t need this.
HTML
<form action="http://eg.com/upload.php"
method="post">
</form>
RESULT
SUBMIT BUTTON
HTML
<form action="http://eg.com/email.php">
<p>Subscribe to our email list:</p>
<input type="submit"
value="Subscribe" />
</form>
RESULT
IMAGE BUTTON (does submit)
HTML
<form action="http://eg.com/email.php">
<p>Subscribe to our email list:</p>
<input type="image"
src="images/subscribe.jpg"
width="100" height="20" />
</form>
RESULT
BUTTONS: Don’t use <button> inside
a form!
<form action="http://eg.com/add.php">
HTML
<button>
<img src="images/add.gif" alt="add"
width="10" height="20" />
</button>
</form>
This submits the form, like <input type=“submit”> or <input type=“image”>.
Tip from www.w3schools.com: If you use the <button> element in an
HTML form, different browsers may submit different values. Use <input> to
create buttons in an HTML form.
• Let’s follow this rule.
HIDDEN FORM CONTROLS
And fix pg. 162: replace <button> with <input>
HTML
<fieldset>
<legend>Contact details</legend>
<label>Email:<br />
<input type="text" name="email"></label>
<br />
<label>Mobile:<br />
<input type="text" name="mobile"></label>
<br />
<label>Telephone:<br />
<input type="text" name="tel"></label>
</fieldset>
RESULT
HTML5: FORM VALIDATION
Add required attribute
HTML
<label for="username">Username:</label>
<input type="text" name="username"
required="required" />
<label for="password">Password:</label>
<input type="password" name="password"
required="required" />
online
HTML5: DATE INPUT
HTML
HTML
HTML
online
SUMMARY