HTML - Part I
HTML - Part I
Web Development 1
Introduction to HTML (Part 1)
HEADLINE
Digital versions
often have similar
Sub- structure
Heading
TEXT
IMAGE
Structure in Word Docs.
Headings and
The
Maininformation
heading andis
subheadings
expanded
importantand
information
may use
reflect hierarchy
subheadings
appear first
of information
HTML – general facts
HTML uses tags (referred as elements), which act like
containers and tell you about the information that lies between
them.
Tags usually come in pairs. Opening tags denote the start of a
piece of content; closing tags denote the end.
Opening tags can carry attributes, which tell us more about the
content of that element. Each attribute require a name and a
value.
Every HTML document contains a start <html> tag and an
end </html> tag
Comments in HTML always begin with <!-- and end with -->.
The browser ignores all text inside a comment
A Closer Look at TAGs
CHARACTER CHARACTER
FORWARD SLASH
ATTRIBUTE
NAME
ATTRIBUTE
VALUE
<html>
<body>
<h1>This is the Main Heading</h1>
<h2>This is a Sub-Heading</h2>
<h2>Another Sub-Heading</h2>
</body>
</html>
Syntax – head, title
Every HTML document contains a head element which
generally contains:
◦ A title
head element
◦ generally is not rendered in the display window
The title element:
◦ Names a web page
◦ Usually appears in the colored bar (called the title bar) at
the top of the browser window
◦ Is the text identifying a page when users add your page
to their list of Favorites or Bookmarks
Syntax - Example
HTML Tag Syntax
<tag attribute1="value1" attribute2="value2">some text</tag>
earth.</p>
Line Breaks – br
<p>The Earth<br />gets one hundred tons heavier
every day<br />due to falling space dust.</p>
LINKING
Introduction to HTML
Syntax – Linking
A hyperlink references or links to other resources, such as HTML
documents and images
Web browsers typically underline text hyperlinks and color them blue
by default
Users can insert links with the a (anchor) element.
◦ The href attribute specifies the resource (e.g., page, file, e-mail
address) being linked
◦ Anchors can link to an e-mail address using a
mailto:emailaddress
When a user clicks this type of anchored link, most browsers launch the
default e-mail program (e.g., Outlook Express) to initiate an e-mail
message addressed to the linked address
Syntax – Linking
<a href="http://squ.edu.om">SQU</a>
• <a href="http://omanair.com">OmanAir</a>
• <a href="http://alwatan.com">Al-Watan</a>
• <a href="http://facebook.com">Facebook</a>
• <a href="http://eoman.com">eOman</a>
• OmanAir
• Al-Watan
• Facebook
• eOman
Linking to Other Pages on the
Same Site
• <a href="index.html">Home</a>
• <a href="about.html">About Us</a>
• <a href="products.html">Products</a>
• <a href="contact.html">Contact Us</a>
• Home
• About Us
• Products
• Contact Us
DIRECTORY examplearts
STRUCTURE 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
DIRECTORY examplearts
STRUCTURE index.html
movies
cinema
index.html
listings.html
ROOT FOLDER reviews.html
dvd
index.html
listings.html
reviews.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
DIRECTORY examplearts
STRUCTURE index.html
movies
cinema
index.html
listings.html
CHILD reviews.html
dvd
index.html
listings.html
reviews.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
DIRECTORY examplearts
STRUCTURE index.html
movies
cinema
index.html
listings.html
CHILD reviews.html
PARENT dvd
index.html
listings.html
reviews.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
DIRECTORY examplearts
STRUCTURE index.html
movies
cinema
index.html
listings.html
CHILD reviews.html
PARENT dvd
index.html
GRANDCHILD
listings.html
reviews.html
music
index.html
listings.html
reviews.html
theater
index.html
listings.html
reviews.html
DIRECTORY examplearts
STRUCTURE index.html
movies
cinema
index.html
listings.html
CHILD reviews.html
PARENT dvd
index.html
GRANDCHILD
listings.html
GRANDPARENT 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
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
SAME index.html
reviews.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
SAME index.html
reviews.html listings.html
reviews.html
CHILD dvd
music/index.html 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
SAME index.html
reviews.html listings.html
reviews.html
CHILD dvd
music/index.html index.html
listings.html
PARENT reviews.html
../index.html music
index.html
GRANDCHILD listings.html
movies/dvd/index.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
CHILD dvd
music/index.html index.html
listings.html
PARENT reviews.html
../index.html music
index.html
GRANDCHILD listings.html
movies/dvd/index.html
reviews.html
GRANDPARENT theater
../../index.html index.html
listings.html
reviews.html
Syntax – Email Links
opens in a
new window
If an image
has the
wrong
dimensions, it
can look
squished.
Image Dimensions
STRAIGHT
TRANSPARENT PNG
DIAGONAL
TRANSPARENT PNG
ROUND
TRANSPARENT PNG
SEMI-OPAQUE
TRANSPARENT PNG
DROP-SHADOW
HTML5: 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 & Caption
IMAGES – Summary
The <img> element is used to add images to a web
page.
You must always specify a src attribute to indicate the
source of an image and an alt attribute to describe the
content of an image.
You should save images at the size you will be using
them on the web page and in the appropriate format.
Photographs are best saved as JPEGs; illustrations or
logos that use flat colors are better saved as GIFs.
LISTS
Introduction to HTML
THREE LIST TYPES
NAME
Username = Ivy
VALUE
Syntax – form
A form begins with the form element
◦ Attribute method specifies how the form’s data is sent to
the web server
◦ The action attribute of the form element specifies the
script (page) to which the form data will be sent
Syntax – form
<form action="join.php" method="get">
</form>
<label for="username">Username:</label>
<input type="text" name="username"
id="username" />
</form>
<label for="username">Username:</label>
<input type="text" name="username"
id="username" />
<label for="password">Password:</label>
<input type="password" name="password"
id="password" />
</form>
cols: sets the width of the textarea (in average character width)
rows: sets the number of rows the textarea spans
Syntax – form: textarea
Syntax – form: radio button
<p>Please select your favorite color:<br />
<input type="radio" name="color"
value="red" id="red" checked="checked" />
<label for="red">Red</label>
Drop down list (or "select") boxes allows the user to pick one
from several options. They are useful when there are long
lists (e.g. a country selector) and not enough space to show
each option.
Adding the attribute size="number" attribute to the select
element will change the element to a multiple select box
Syntax – form: dropdown box
Syntax – form: file input box
<form action="upload.php" method="post"
enctype="multipart/form-data">
Upload photo:
<input type="file" name="photo" /><br />
<input type="submit" value="Upload" />
</form>
Readings…
Chapter 2 (Internet & WWW: How to program
– 5th Edition)