CS170 Chapter04 HTML
CS170 Chapter04 HTML
Chapter 04
HTML
Web Pages
• Web pages:
• Metadata (<tags>)
• Hypertext Markup Language (HTML)
• Browser
1
9/21/2020
• Free programs:
– A browser (Firefox or Chrome recommended)
– A text editor
• Notepad++ for Windows
• Brackets
• Atom
• Gedit
2
9/21/2020
<body>
<p>Hello, World!</p>
</body>
</html>
3
9/21/2020
• Examples:
• <hr> (thematic change):
• produces a horizontal line
•
• <br> (break):
• continues the text on the next line
12
4
9/21/2020
More tags
<pre> tag : preformatted information
Comments in HTML
<!-- This is a comment -->
13
é displays é
È displays È
15
5
9/21/2020
Image Tags
19
21
6
9/21/2020
Headings in HTML
• HTML heading tags:
– <h1> and </h1> level one
– <h2> and </h2> level two
–…
– <h6> and </h6> level six
• Headings display content on a new line
22
Bertrand Russell
Format:
<a href=“some hyperlink”>some text</a>
23
7
9/21/2020
24
25
8
9/21/2020
Relative Pathnames
26
• Programming language
• Styles
elem_name {prop1:value1;…;propN:valueN}
<style>
body {background-color: black; color: white;}
</style>
27
9
9/21/2020
Inline Styling
• applies to a tag in only one place
(attached to a tag):
29
Span
From this:
To this:
30
10
9/21/2020
Span
My favorite colors are
<span style="color:red">red</span>,
<span style="color:green">green</span>, and
<span style="color:blue">blue</span> and my favorite font is
<span style="font-family:Times New Roman">Times New Roman</span>.
31
Style Files
• Consolidation of CSS entries in one file
• Example: myFaveStyle.css
33
11
9/21/2020
The Cascade
• Style Information sources
• (from lowest to highest priority):
• default: browser
• external: separate CSS file
• head section: <style> tags
• inherited: properties set original tag
• tagged: style attribute inside another tag
34
35
12
9/21/2020
• Otherwise it behaves
like the unnumbered
list
36
37
13
9/21/2020
Handling Tables
• Table tags:
• <table>, </table>
Rows:
− <tr>, </tr> tags
Cells:
− <td>, </td> tags
39
Handling Tables
• Captions
− <caption> Country Data </caption>
⚫ Column headings
− <th> Country </th>
40
14
9/21/2020
File Structure
g1 g2
41
<a href="russellbio.html">Russell</a>
<a href="biographies/russellbio.html">Russell</a>
42
15
9/21/2020
Example:
43
Margin
Border
Padding
49
16