HTML Course Introduction For Igcse
HTML Course Introduction For Igcse
1
Open the Start Screen (the window symbol at the bottom left on your screen). Type Notepad.
Windows 7 or earlier:
Open Start > Programs > Accessories > Notepad
</body>
</html>
2
Step 3: Save the HTML Page
Save the file on your computer. Select File > Save as in the Notepad menu.
Name the file "index.htm" and set the encoding to UTF-8 (which is the preferred encoding for
HTML files)
3
HTML Documents
All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
4
HTML Paragraphs
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
HTML Links
HTML links are defined with the <a> tag:
HTML Images
HTML images are defined with the <img> tag.
The source file (src), alternative text (alt), width, and height are provided as
attributes:
Example
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
5
An HTML element is defined by a start tag, some content,
and an end tag.
<tagname>Content goes here...</tagname>
HTML Attributes
6
1. Absolute URL - Links to an external image that is hosted on another website. Example:
src="https://www.w3schools.com/images/img_girl.jpg".
Notes: External images might be under copyright. If you do not get permission to use it, you
may be in violation of copyright laws. In addition, you cannot control external images; it can
suddenly be removed or changed.
2. Relative URL - Links to an image that is hosted within the website. Here, the URL does not
include the domain name. If the URL begins without a slash, it will be relative to the current
page. Example: src="img_girl.jpg". If the URL begins with a slash, it will be relative to the
domain. Example: src="/images/img_girl.jpg".
Tip: It is almost always best to use relative URLs. They will not break if you change domain.
EXAMPLE 10;
7
<!DOCTYPE html>
<html>
<body>
<p>The alt attribute should reflect the image content, so users who cannot see the image
get an understanding of what the image contains:</p>
</body>
</html>
EXAMPLE 11;
See what happens if we try to display an image that does not exist:
<img src="img_typo.jpg" alt="Girl with a jacket">
<!DOCTYPE html>
<html>
<body>
<p>If we try to display an image that does not exist, the value of the alt attribute
will be displayed instead. </p>
</body>
</html>
HTML Headings
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
8
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
HTML Paragraphs
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
EXAMPLE 12;
<!DOCTYPE html>
<html>
<body>
<p>
This paragraph
ignores it.
</p>
<p>
This paragraph
ignores it.
9
</p>
<p>
The number of lines in a paragraph depends on the size of the browser window. If you resize the
browser window, the number of lines in this paragraph will change.
</p>
</body>
</html>
HTML Styles
<tagname style="property:value;">
EXAMPLE OF ATTRIBUTE;
<!DOCTYPE html>
<html>
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Text Color
The CSS color property defines the text color for an HTML element:
10
Fonts
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
Text Size
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
Text Alignment
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
11
<!DOCTYPE html>
<html>
<body>
<p style="background-color:Tomato;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex
ea commodo consequat.
</p>
</body>
</html>
EXAMPLE OF COLORS;1
<!DOCTYPE html>
<html>
<body>
12
<h1 style="background-color:rgb(255, 165, 0);">rgb(255, 165, 0)</h1>
</body>
</html>
#rrggbb
Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00 and ff (same as
decimal 0-255).
For example, #ff0000 is displayed as red, because red is set to its highest value (ff), and the other
two (green and blue) are set to 00.
Another example, #00ff00 is displayed as green, because green is set to its highest value (ff), and
the other two (red and blue) are set to 00.
To display black, set all color parameters to 00, like this: #000000.
To display white, set all color parameters to ff, like this: #ffffff.
13
EXAMPLE OF COLORS2;
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:#ff0000;">#ff0000</h1>
<h1 style="background-color:#0000ff;">#0000ff</h1>
<h1 style="background-color:#3cb371;">#3cb371</h1>
<h1 style="background-color:#ee82ee;">#ee82ee</h1>
<h1 style="background-color:#ffa500;">#ffa500</h1>
<h1 style="background-color:#6a5acd;">#6a5acd</h1>
</body>
</html>
Creating an attractive page will be difficult for those who are not experts in CSS. Without using CSS, you
will not be able to make the web page, more attractive. So in order to make a web page, we need to
have a knowledge of HTML and CSS.
Creating structure: In this section, we will create a simple structure of web page by using <li> and
<section> tags.
<!DOCTYPE html>
<html>
<head>
<title>
</title>
14
</head>
<body>
<ul class="nav-list">
<div class="logo">
<img src="logo.png">
</div>
<li><a href="#course">Courses</a></li>
</ul>
<div class="rightNav">
</div>
</nav>
<section class="firstsection">
<div class="box-main">
<div class="firstHalf">
Web Technology
</h1>
<p class="text-small">
15
pages. A markup language is used
format.
</p>
</div>
</div>
</section>
<section class="secondsection">
<div class="box-main">
<div class="secondHalf">
C Programming
</h1>
<p class="text-small">
16
or compiler development.
</p>
</div>
</div>
</section>
<section class="section">
<div class="paras">
underlying architecture.
</p>
</div>
<div class="thumbnail">
</div>
</section>
<footer class="background">
17
<p class="text-footer">
</p>
</footer>
</body>
</html>
HTML tags dictate the overall structure of a page and how the elements within
them will be displayed in the browser. Commonly used HTML tags include:
18
● <h1> which describes a top-level heading.
● <h2> which describes a second-level heading.
● <p> which describes a paragraph.
● <table> which describes tabular data.
● <ol> which describes an ordered list of information.
● <ul> which describes an unordered list of information.
<table>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
</tr>
<tr>
<td>Cell 4</td>
<td>Cell 5</td>
<td>Cell 6</td>
</tr>
</table>
19
<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
</tr>
<tr>
<td>Hillary</td>
<td>Nyakundi</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Lary</td>
<td>Mak</td>
<td>[email protected]</td>
</tr>
</table>
21
<table>
<tr>
<th scope="value">
</tr>
</table>
<table>
<tr>
<th></th>
<th scope="col">Semester</th>
<th scope="col">Grade</th>
</tr>
<tr>
<td>1</td>
<td>Jan - April</td>
<td>Credit</td>
</tr>
<tr>
<td>2</td>
<td>May - August</td>
<td>Pass</td>
</tr>
<tr>
<td>2</td>
<td>September - December</td>
<td>Distinction</td>
</tr>
</table>
22
How to Use Cell Spanning in an HTML Table
Perhaps you have come across cells that stretch across two or more columns or
rows in a table. That's called cell spanning. he same features can be applied in an
HTML table by using two cell attributes, colspan for horizontal spanning and
rowspan for vertical spanning.
24
How to Add a Table Header, Body, & Footer in HTML
Tables
In a table they are divided by using attributes namely:
<tbody>
<tr>
<td>Sales</td>
<td>Profit</td>
<td>Sales</td>
<td>Profit</td>
</tr>
<tr>
<td>$200,00</td>
<td>$50,00</td>
<td>$300,000</td>
<td>$70,000</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan= "4">November was more produstive</th>
</tr>
</tfoot>
25
</table>
26
<TABLE BORDER=1 WIDTH="50%">
<TR>
<TD>Red</TD>
<TD>Green</TD>
<TD>Blue</TD>
</TR>
<TR>
<TD>Orange</TD>
<TD>Yellow</TD>
<TD>Purple</TD>
</TR>
</TABLE>
27
</TR>
28
</TR>
<TR>
<TD>Orange</TD>
<TD>Yellow</TD>
<TD>Purple</TD>
</TR>
</TABLE>
<!DOCTYPE html>
<html>
<style>
table {
border:1px solid black;
padding: 10px;
}
th, td{
border:1px solid black;
padding: 20px;
}
</style>
<body>
<h2>Tables in HTML</h2>
<table style="width: 50%">
<tr>
<th>Name </th>
<th>Job role</th>
</tr>
<tr>
29
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
31
</tr>
</table>
Exp:2
<table>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4 </td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4</td>
</tr>
</table>
Exp:3
32
<table border="1">
<tr>
<td>Row 1</td>
<td>Row 2</td>
<td>Row 3</td>
</tr>
<tr>
<td>Row 1</td>
<td>Row 2</td>
<td>Row 3</td>
</tr>
</table>
Exp:4
<table border="1">
<tr>
33
<th></th>
<th>Column Header 1</th>
<th>Column Header 2</th>
<th>Column Header 3</th>
</tr>
<tr>
<th>Row Header 1</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<tr>
<th>Row Header 2</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<tr>
<th>Row Header 3</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
</table>
34
How to use and implement HTML
Chrome and Firefox both include HTML developer tools that allow for the
immediate viewing of a webpage's complete HTML file, along with the
ability to edit HTML on the fly and immediately incorporate changes within
the internet browser.
It's important to note as well that the language HTML works with is basic
English. Non-English characters -- or letters -- such as Chinese, or special
symbols -- like letters with accent marks -- may not display correctly on a
webpage by default. In order to accommodate special character sets, users
need to specify the character encoding with an element that looks like this:
35
<meta charset="utf-8"/>. In this case, utf-8 is the character set. Utf-8 is
HTML's default English charset.
Add the opening and closing <head> tags inside of the <html> tags. Next,
add two additional lines of HTML code inside the <head> tags like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sammy’s First Website</title>
</head>
</html>
Another syntax rule is that HTML attributes should be enclosed within single or double
quotes.The best advice for choosing between single and double quotes is to keep the usage
consistent across all the documents.
36