Lab 1 - Basic HTML
Lab 1 - Basic HTML
1.1. HTML Elements ................................................................................................. 2 1.1.1. HTML Elements .......................................................................................... 2 1.1.2. HTML Element Syntax ............................................................................... 2 1.1.3. Nested HTML Elements.............................................................................. 2 1.1.4. HTML Document Example ......................................................................... 2 1.2. HTML Basic ....................................................................................................... 2 1.2.1. HTML Headings.......................................................................................... 2 1.2.2. HTML Paragraphs ....................................................................................... 3 1.2.3. HTML Links................................................................................................ 4 1.2.4. HTML Images ............................................................................................. 4 1.3. HTML Attributes ................................................................................................ 4 1.3.1. HTML Attributes......................................................................................... 4 1.3.2. Always Quote Attribute Values .................................................................. 4 1.3.3. HTML Tip: Use Lowercase Attributes ....................................................... 5 1.4. HTML Links....................................................................................................... 5 1.4.1. Hyperlinks, Anchors, and Links.................................................................. 5 1.4.2. An HTML Link ........................................................................................... 5 1.4.3. The href Attribute ........................................................................................ 5 1.4.4. The target Attribute ..................................................................................... 6 1.4.5. The name Attribute...................................................................................... 6 1.5. HTML Tables ..................................................................................................... 6 1.5.1. Tables .......................................................................................................... 6 1.5.2. Tables and the Border Attribute .................................................................. 7 1.5.3. Headings in a Table ..................................................................................... 7 1.5.4. Empty Cells in a Table ................................................................................ 7 1.6. HTML Styles ...................................................................................................... 8 1.6.1. The HTML Style Attribute .......................................................................... 8 1.6.2. HTML Style Examples................................................................................ 9 1.6.3. Deprecated Tags and Attributes .................................................................. 9 1.7. HTML Lists ........................................................................................................ 9 1.7.1. Unordered Lists ........................................................................................... 9 1.7.2. Ordered Lists ............................................................................................. 10 1.7.3. Definition Lists .......................................................................................... 10 1.8. HTML Text Formatting ................................................................................... 11 1.8.1. HTML Formatting Tags ............................................................................ 11 1.8.2. Text Formatting Tags ................................................................................ 11 1.8.3. Citations, Quotations, and Definition Tags ............................................... 11 1.9. Exercises ........................................................................................................... 12 REFERENCES ........................................................................................................ 14
* The start tag is often called the opening tag. The end tag is often called the closing tag.
An HTML element starts with a start tag / opening tag An HTML element ends with an end tag / closing tag The element content is everything between the start and the end tag Some HTML elements have empty content Empty elements are closed in the start tag Most HTML elements can have attributes
Example
<h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3>
Example
<p>This is a paragraph</p> <hr /> <p>This is a paragraph</p> <hr /> <p>This is a paragraph</p>
* HTML Comments
Comments can be inserted in the HTML code to make it more readable and understandable. Comments are ignored by the browser and are not displayed. Comments are written like this:
Example
<!-- This is a comment -->
Example
<p>This is a paragraph</p> <p>This is another paragraph</p>
Example
<p>This is a paragraph <p>This is another paragraph
The example above will work in most browsers, but don't rely on it. Forgetting the end tag can produce unexpected results or errors.
Example
<p>This is<br />a para<br />graph with line breaks</p> The <br /> element is an empty HTML element. It has no end tag.
Example
<a href="http://www.w3schools.com">This is a link</a>
Example
<img src="w3schools.jpg" width="104" height="142" />
HTML elements can have attributes Attributes provide additional information about the element Attributes are always specified in the start tag Attributes come in name/value pairs like: name="value"
Attribute Example
HTML links are defined with the <a> tag. The link address is provided as an attribute:
Example
<a href="http://www.w3schools.com">This is a link</a>
Example
<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>
</tr> <tr> <td>row 2, cell 1</td> <td></td> </tr> </table> How it looks in a browser: row 1, cell 1 row 1, cell 2 row 2, cell 1 Note that the borders around the empty table cell are missing (NB! Mozilla Firefox displays the border). To avoid this, add a non-breaking space ( ) to empty data cells, to make the borders visible: <table border="1"> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td> </td> </tr> </table> How it looks in a browser: row 1, cell 1 row 1, cell 2 row 2, cell 1
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. <ul> <li>Coffee</li> <li>Milk</li> </ul> Here is how it looks in a browser:
Coffee Milk
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
10
Coffee Black hot drink Milk White cold drink Inside the <dd> tag you can put paragraphs, line breaks, images, links, other lists, etc.
11
The browser will insert quotation marks around the quotation. A short quotation is marked up as follows: <q> Here is a short quotation here is a short quotation </q>
1.9. Exercises
Ex1. - Create a simple HTML page as this below webpage: <html> <body> <h1 style="text-align:center">This is a HTML practice exercise</h1> <hr /> <p>The heading above is aligned to the center of this page. The heading above is aligned to the center of this page. The heading above is aligned to the center of this page.</p> <hr /> <p> This paragraph contains a lot of lines in the source code, but the browser ignores it. </p> <hr /> <p> This paragraph contains a lot of spaces 12
in the source code, but the browser ignores it. </p> <hr /> <h5>This is heading 5</h5> <hr /> <h6>This is heading 6</h6> </body> </html> - You should modify each tag by yourself and watch the effect of that modification. Ex2. - Create a simple HTML page as your personal webpage. - Below are the suggested layout: Personal Details Image
Education process Working process Society activities Skills Experiences Certifications Hobbies Desire
13
REFERENCES
[1] http://www.w3schools.com/html
14