Unit 1
Unit 1
</html>
HTML Page Structure
HTML Attributes
• With CSS, you can control the color, font, the size of text, the spacing
between elements, how elements are positioned and laid out,
section
<!DOCTYPE html>
<html> <head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style> </head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
3.External
home.html
styles.css
<!DOCTYPE html> body {
background-color: powderblue;
<html> }
<head> h1 {
color: blue;
<link rel="stylesheet" href="styles.css"> }
</head> p{
color: red;
<body> }
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Links
• HTML links are hyperlinks.
• You can click on a link and jump to another document.
• When you move the mouse over a link, the mouse arrow will turn into
a little hand
HTML Link
• <!DOCTYPE html>
• <html>
• <body>
• <h1>HTML Links</h1>
• <p><a
href="https://www.w3schools.co
m/">Visit
W3Schools.com!</a></p>
• </body>
• </html>
HTML Images
<!DOCTYPE html>
<html>
<body>
<h2>HTML Image</h2>
<img src="pic_trulli.jpg" alt="Trulli"
width="500" height="333">
</body>
</html>
HTML Tables
<table>
<tr> --> Table row --> Each table row starts with a <tr> and ends with
a </tr> tag
<td> --> Table data --> Everything between <td> and </td> are the
content of the table cell.
HTML Tables
<!DOCTYPE html>
<tr>
<html>
<td>Alfreds Futterkiste</td>
<style>
<td>Maria Anders</td>
table, th, td {
<td>Germany</td>
border:1px solid black;
</tr>
}
<tr>
</style>
<td>Centro comercial Moctezuma</td>
<body>
<td>Francisco Chang</td>
<td>Mexico</td>
<h2>A basic HTML table</h2>
</tr>
</table>
<table style="width:100%">
<tr>
<p>To understand the example better, we have added borders
<th>Company</th>
to the table.</p>
<th>Contact</th>
<th>Country</th>
</body>
</tr>
</html>
HTML Tables
HTML Lists
• HTML lists allow web developers to group a set of related items in
lists.
HTML Video
• The HTML <video> element is used to show a video on a web page.
Example 1
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
Example 2
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" autoplay>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
HTML Audio
• The HTML <audio> element is used to play an audio file on a web page.
• The controls attribute adds audio controls, like play, pause, and volume.
• The <source> element allows you to specify alternative audio files which
the browser may choose from.
• The text between the <audio> and </audio> tags will only be displayed in
browsers that do not support the <audio> element
Example
<!DOCTYPE html>
<html>
<body>
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3"
type="audio/mpeg">
Your browser does not support the audio
element.
</audio>
</body>
</html>
HTML Semantic Elements
• Semantic elements = elements with a meaning.
• Examples of non-semantic elements: <div> and <span> - Tells nothing about its
content.
• In HTML there are some semantic elements that can be used to define different
parts of a web page:
HTML Semantic Elements
HTML Semantic Elements
1.navigation
• The <nav> element defines a set of navigation links.
<!DOCTYPE html>
<html>
<body>
<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/jquery/">jQuery</a>
</nav>
</body>
</html>
2.aside
<!DOCTYPE html> <p>My family and I visited The Epcot center this summer.</p>
<html> <aside>
<head> <p>The Epcot center is a theme park at Walt Disney World.</p>
<style> </aside>
aside { <p>My family and I visited The Epcot center this summer.</p>
width: 30%; </body>
padding-left: 15px; </html>
margin-left: 15px;
float: right;
font-style: italic;
background-color: lightgray;
}
</style>
</head>
<body>
3.figure
<!DOCTYPE html>
<html>
<body>
<h2>Places to Visit</h2>
<p>Puglia's most famous sight is the unique
conical houses (Trulli) found in the area around
Alberobello, a declared UNESCO World Heritage
Site.</p>
<figure>
<img src="pic_trulli.jpg" alt="Trulli"
style="width:100%">
<figcaption>Fig.1 - Trulli, Puglia,
Italy.</figcaption>
</figure>
</body>
</html>
4.footer
<!DOCTYPE html>
<html>
<body>
<footer>
<p>Author: Hege Refsnes</p>
<p><a
href="mailto:[email protected]">[email protected]</a></
p>
</footer>
</body>
</html>
5.section
<!DOCTYPE html>
<html>
<body>
<section>
<h1>WWF</h1>
<p>The World Wide Fund for Nature (WWF) is an international organization working on issues
regarding the conservation, research and restoration of the environment, formerly named the
World Wildlife Fund. WWF was founded in 1961.</p>
</section>
<section>
<h1>WWF's Panda symbol</h1>
<p>The Panda has become the symbol of WWF. The well-known panda logo of WWF originated
from a panda named Chi Chi that was transferred from the Beijing Zoo to the London Zoo in the
same year of the establishment of WWF.</p>
</section>
</body>
</html>
HTML Forms
• An HTML form is used to collect user input. The user input is most often
sent to a server for processing.
• The HTML <form> element is used to create an HTML form for user input
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe">
</form>
• The <label> element also helps users who have difficulty clicking on
very small regions (such as radio buttons or checkboxes) -
• because when the user clicks the text within the <label> element, it
toggles the radio button/checkbox.
• The for attribute of the <label> tag should be equal to the id attribute
of the <input> element to bind them together.
3.Radio Buttons
• The <input type="radio"> defines a radio button.
• Radio buttons let a user select ONE of a limited number of choices.
<h2>HTML Forms</h2>
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called
"/action_page.php".</p>
</body>
</html>
CSS Multiple Backgrounds
• CSS allows you to add multiple background images for an element,
through the background-image property.
</body>
</html>
<div> tag
• The <div> tag defines a division or a section in an HTML document.
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:Tomato;">Tomato</h1>
<h1 style="background-color:Orange;">Orange</h1>
<h1 style="background-color:DodgerBlue;">DodgerBlue</h1>
<h1 style="background-
color:MediumSeaGreen;">MediumSeaGreen</h1>
<h1 style="background-color:Gray;">Gray</h1>
<h1 style="background-color:SlateBlue;">SlateBlue</h1>
<h1 style="background-color:Violet;">Violet</h1>
<h1 style="background-color:LightGray;">LightGray</h1>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Shadows
• With CSS you can add shadow to text and to elements.
1. text-shadow
2. box-shadow
Text Shadow
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-shadow: 2px 2px red;
}
</style>
</head>
<body>
<h1>Text-shadow effect!</h1>
</body>
</html>
Box Shadow
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
padding: 15px;
background-color: coral;
box-shadow: 10px 10px;
}
</style>
</head>
<body>
</body>
</html>
Text
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: blue;
}
h1 {
color: green;
}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<p>This is an ordinary paragraph. Notice that this text is blue.
The default text color for a page is defined in the body
selector.</p>
<p>Another paragraph.</p>
</body>
</html>
Transformations
• CSS transforms allow you to move, rotate, scale, and skew elements.
• transform
div#myDiv {
Transformations
transform: rotate(20deg);
}
<!DOCTYPE html> </style>
<html> </head>
<head> <body>
<style>
div { <h1>The rotate() Method</h1>
width: 300px;
height: 100px; <p>The rotate() method rotates an element clockwise or
background-color: yellow; counter-clockwise.</p>
border: 1px solid black;
} <div>
This a normal div element.
</div>
<div id="myDiv">
This div element is rotated clockwise 20 degrees.
</div>
</body>
</html>