chapter 2 html basics - skkumonet.skku.edu/wp-content/uploads/2018/08/chapter-02... ·...

71
Web Programming Networking Laboratory 1/70 Sungkyunkwan University Copyright 2000-2012 Networking Laboratory Copyright 2000-2018 Networking Laboratory Chapter 2 HTML basics Prepared by D. T. Nguyen and H. Choo

Upload: others

Post on 19-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 1/70

Sungkyunkwan University

Copyright 2000-2012 Networking LaboratoryCopyright 2000-2018 Networking Laboratory

Chapter 2

HTML basics

Prepared by D. T. Nguyen and H. Choo

Page 2: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 2/70

Contents

World wide web fundamental

HTML editors

Basic structure of an HTML document

Paragraph and Text format

Table and list

More on HTML

Page 3: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 3/70

What is the World Wide Web?

World Wide Web (WWW) is also called the Web

The web is an information space where documents and other web

resources are accessible via the Internet [1]

All the computers accessing the WWW use a communication

standard called HTTP.

[1] https://en.wikipedia.org/wiki/World_Wide_Web

Page 4: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 4/70

How does the WWW work?

Web information is stored in documents called web pages.

Web pages are files stored on computers called web servers.

Computers reading the web pages are called web clients.

Web clients view the pages with a program called a web browser.

Popular browsers are Internet Explorer, Google Chrome and

Mozilla Firefox.

Page 5: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 5/70

Fetching and displaying a Web page

Fetching:

A browser fetches a page from a web server by a request.

A request is a standard HTTP request containing a page address.

An address may look like this: http://www.someone.com/page.htm.

Displaying:

All web pages contain instructions for display

The browser displays the page by reading these instructions.

The most common display instructions are called HTML tags.

Page 6: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 6/70

Hypertext Markup Language (HTML)

Describes the content and structure of information on a web page

Not the same as the presentation (appearance on screen)

Surrounds text content with opening and closing tags

Each tag's name is called an element

Syntax: <element> content </element>

Example: <p>This is a paragraph</p>

Most whitespace is insignificant in HTML (ignored or collapsed to a

single space)

We will use a new version called HTML5

Page 7: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 7/70

HTML EDITORS

Page 8: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 8/70

HTML EditorsNotepad

Notepad is a simple application comes up with windows allows you to

write some text and store them

No syntax highlighting, plugins, etc.

Page 9: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 9/70

HTML EditorsNotepad++

More advanced text editor, give you a boost to do coding like HTML

Support syntax highlight, plugins for coding convenience

Page 10: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 10/70

HTML EditorsAtom

Within the scope of this lecture, we are using atom for editing HTML

files:

Page 11: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 11/70

Installing Atom.io

Type http://atom.io into your web browser and hit enter

Click “Download” to get a version for your OS

Run the installation file on your computer

Page 12: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 12/70

Atom editor packages

Two must-have packages for the atom editor are atom-live-server and

color-picker

How to install:

File ➔ Settings

[http://code.makery.ch/library/html-css/part1/]

Page 13: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 13/70

Install atom packages

How to install:

Enter name of the package in the search bar, then hit enter and click

install

[http://code.makery.ch/library/html-css/part1/]

Page 14: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 14/70

Create your first page with Atom (1/5)

Create a folder on your computer for the html project, e.g. “L02”

Open Atom, then File ➔ Open Folder to browse to the created folder

Page 15: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 15/70

Create your first page with Atom (2/5)

Right-click on the “project” pane and choose “New File”. Name the file

“index.html”

Page 16: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 16/70

Create your first page with Atom (3/5)

Type the following code in the index.html file:

Page 17: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 17/70

Create your first page with Atom (4/5)

Click Packages ➔ atom-live-server ➔ Start server

Page 18: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 18/70

Create your first page with Atom (5/5)

Edit your web content. As long as you save the file, your change will

be displayed in the browser

If not, click F5 in the browser

Page 19: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 19/70

HTML BASIC STRUCTURE

Page 20: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 20/70

Sample web page (1/2)

Go to the link http://monet.skku.edu/~mc2016/

Page 21: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 21/70

Sample web page (2/2)

Go to the link http://icoin.org/

Page 22: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 22/70

Structure of an HTML document

A simple HTML document

<!DOCTYPE html><html><head>

<title>MC 2016</title>

</head><body>

…</body></html>

Page 23: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 23/70

<!DOCTYPE>

Specify the type and version of HTML used in the web page

Page 24: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 24/70

<head> tag

The <head> element is a container for metadata (data about data) and

is placed between the <html> tag and the <body> tag.

HTML metadata is data about the HTML document. Metadata is not

displayed.

Metadata typically define the document title, character set, styles,

links, scripts, and other meta information.

The following tags describe metadata: <title>, <style>, <meta>, <link>,

<script>, and <base>.

Page 25: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 25/70

Page Title: <title>

Placed within the <head> of the page

Displayed in the web browser's title bar and when bookmarking the

page, otherwise not visible to the user as page content

<title>Chapter 2: HTML Basics

</title>

Page 26: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 26/70

Structure of an HTML content

HTML5 Elements such as article, header, footer, aside and many more

are used for semantics - to add meaning to your code.

Belong to the <body>

Page 27: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 27/70

<header> tag (1/2)

The <header> element represents a container for introductory content

or a set of navigational links.

A <header> element typically contains:

logo or icon (website branding)

Navigation elements

You can have several <header> elements in one document.

Page 28: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 28/70

<header> tag (2/2)

<header> example

Header

Page 29: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 29/70

Headings: <h1>, <h2>, ..., <h6>

To separate major areas of the page

<h1>Sungkyunkwan University</h1><h2>Department of Electrical and Computer Engineering</h2><h3>Class of Web Programming</h3>

Page 30: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 30/70

<article> tag (1/2)

The <article> tag is a standalone piece of content (e.g. entire blog

post, including title, author, etc.)

<article><h2>GENERAL INFORMATION</h2><p>The 33<sup>rd</sup> International Conference on Informati

on Networking (ICOIN) will take place in Kuala Lumpur,…</p>

</article>

Page 31: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 31/70

<article> tag (2/2)

Example of an <article>

Page 32: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 32/70

<section> tag (1/2)

Used to either group different articles into different purposes or

subjects, or to define the different sections of a single article.

<article><section>

GENERAL INFORMATION</section>

<section>IMPORTANT DATES

</section></article>

Page 33: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 33/70

<section> tag (2/2)

Used to either group different articles into different purposes or

subjects, or to define the different sections of a single article.

<section> <!—WEATHER FORCAST--><article>

Weather day 1</article>

<article>Weather day 2

</article></section>

Page 34: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 34/70

<footer> tag

The <footer> tag defines a footer for a document or section.

A <footer> element typically contains:

authorship information

copyright information

contact information

sitemap

back to top links

related documents

You can have several <footer> elements in one document.

Page 35: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 35/70

<footer> tag

<footer> example

<footer>footer content…

</footer>

Page 36: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 36/70

TEXT & PARAGRAPH

Page 37: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 37/70

Block vs. inline elements

Block elements contain an entire large region of content

A block-level element always starts on a new line and takes up the full

width available (stretches out to the left and right as far as it can).

Blocking out any other elements from sitting next to it on the left or right

Examples: paragraphs, lists, table cells etc.

Inline elements are those who only take up as much width as is

needed to display the contents of the element, thereby allowing other

elements to be in line with the inline element.

Example: images, links

Page 38: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 38/70

Text formatting (1/3)

Formatting text style with following attributes:

<b> - Bold text

<strong> - Important text

<i> - Italic text

<em> - Emphasized text

<mark> - Marked text

<small> - Small text

<del> - Deleted text

<ins> - Inserted text

<sub> - Subscript text

<sup> - Superscript text

Page 39: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 39/70

Text formatting (2/3)

Example of text formatting

<p>This text is normal.</p><p><b>This text is bold.</b></p><strong>This text is strong</strong><i>This text is italic</i><em>This text is emphasized</em><h2>HTML <small>Small</small> Formatting</h2><h2>HTML <mark>Marked</mark> Formatting</h2><p>My favorite color is <del>blue</del> red.</p><p>My favorite <ins>color</ins> is red.</p><p>This is <sub>subscripted</sub> text.</p><p>This is <sup>superscripted</sup> text.</p>

Page 40: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 40/70

Text formatting (3/3)

Styling text with <span>

Possible to tune color, background-color, font-family

Good fonts for website (15):

Arial, Helvetica, Times New Roman, Times, Courier New, Courier, Verdana,

Georgia, Palatino, Garamond, Bookman, Comic Sans MS, Trebuchet MS, Arial

Black, Impact,

Page 41: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 41/70

<p> tag

Placed within the <body> of the page

<p>The main purpose of ICOIN 2019 is to improve our research by achieving the highest capability and encourage open discussions on computer communication and networking technologies…</p>

Page 42: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 42/70

<br> tag

Forces a line break in the middle of a block element (inline)

Warning: Don’t overuse <br> tag in a line

<p>The 2016 International Conference on Computational Science and its Applications (ICCSA 2016) <br>July 04 - 07, 2016, at the Park Plaza Beijing Science Park Hotel, Beijing, China.</p>

Page 43: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 43/70

<pre> tag

<pre> display text on screen as programmer typed

<pre>Paper Submission Due.Acceptance Notification.

</pre>Camera-ready Papers Due.<br>Conference Dates.

Page 44: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 44/70

Horizontal line

The <hr> element is used to separate content (or define a change) in

an HTML page.

<!DOCTYPE html><html><body>

<h1>HTML</h1><p>HTML is a language for describing web pages.</p>

<hr><h1>CSS</h1>

<p>CSS defines how to display HTML elements.</p></body></html>

Page 45: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 45/70

LINK

Page 46: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 46/70

<a> tag

Links, or "anchors", to other pages (inline)

Uses the href attribute to specify the destination URL, sytax:

Can be absolute (to another web site) or relative (to another page on

this site)

<p>Search for it on <a href="http://www.google.com/">Google</a>

</p>

<a href="url">link text</a>

<p>Search for it on <a href=“cfp.html">Google</a>

</p>

Page 47: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 47/70

Link target attributes

The target attribute specifies a window or a frame where the linked

document is loaded.

Syntax

<a href="" target="_blank|_self|_parent|_top|framename">

Page 48: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 48/70

Bookmarks

Bookmark an HTML element and link to the bookmark

Use ID attribute to define a bookmark in a page

Go to the bookmark in a same page

Go to the bookmark in another page

<h2 id="info">GENERAL INFORMATION</h2>

<a href="#info">Jump to General Info</a>

<a href="home.html#info">Go to General Info</a>

Page 49: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 49/70

<nav> tag

Defines a set of navigation links

<nav> is intended for major block of navigation links

<nav><a href="cfp.html">Call for Papers</a> |<a href="committees.html">Committees</a> |<a href="authors.html">Author Guideline</a> |<a href="chair.html">Chair Guideline</a>

</nav>

Page 50: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 50/70

IMAGES

Page 51: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 51/70

Images

The <img> tag defines an image in an HTML page.

The <img> tag has two required attributes: src and alt.

src specifies URL of an image

alt specifies an alternate text for an image

<img border="0" src="everland.jpg" alt="Everland" width="300"height="230">

Page 52: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 52/70

ImagesExample

<!DOCTYPE html><html><body>

<h2>Everland</h2>

<img border="0" src="everland.jpg" alt="Everland"width="300" height="230">

</body></html>

Page 53: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 53/70

Imagesalt attribute

Specify the alternate text to be displayed when the browser fails to

display the image on the screen for some reason

<img border="0" src="everland.jpg" alt="Everland" width="300" height="230">

Page 54: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 54/70

Image types

JPEG

Suitable for complex, many-color images such as real photographs

Loss compression method is used.

PNG

Suitable for images with fewer colors, such as clip art

Lossless compression method

GIF

Ideal for images in the form of logos or clip art

Supports 256 colors only

It supports transparent backgrounds and animations.

Page 55: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 55/70

TABLE AND LIST

Page 56: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 56/70

Table example

The HTML <table> element

represents tabular data - that is,

information presented in a two-

dimensional table comprised of

rows and columns of cells

containing data.

Page 57: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 57/70

HTML Table

Basic tags:

<tr>: define a row in a table

<th>: define a table header

<td>: define a cell

<th> <th> <th>

<td> <td> <td>

<td> <td> <td>

<td> <td> <td>

<tr>

<tr>

<tr>

<tr>

Page 58: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 58/70

HTML Table:Defining a table

<!DOCTYPE html><html><body>

<h2>Basic HTML Table</h2>

<table style="width:100%"><tr>

<th>Firstname</th><th>Lastname</th>

</tr><tr>

<td>Jill</td><td>Smith</td>

</tr><tr>

<td>Eve</td><td>Jackson</td>

</tr></table>

</body></html>

Page 59: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 59/70

HTML Table:Styling

Border by adding border = “#number”

Spanning rows and columns

Table caption: try it yourself

<table border="1">…</table>

<td rowspan=“2">…</td>

<td colspan=“2">…</td>

<caption> Your caption here!!! </caption>

Page 60: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 60/70

ListUnordered List

<ul> represents a bulleted list of items

<li> represents a single item within the list

<strong> Before your session:</strong><ul>

<li>Check the Program<br><li>Pick up the Materials for Session Chair from

Registration Desk<br><li>Check the Meeting Room<br>

</ul>

Page 61: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 61/70

ListOrdered list

<ol> represents a numbered list of items (block)

<strong> During your session:</strong><ol>

<li>Introduction<br /><li>Time allotment<br /><li>Absent speakers<br />

</ol>

Page 62: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 62/70

Definition list (1/2)

<dl> represents a list of definitions of terms (block)

<dt> represents each term

<dd> is definition of the term

<dl><dt>Text Editor<dd>Program that comes with the default installation of most computer operating

systems that permits the user to save text to a file stripped of any formatting. Often used by web page authors, beginner and hardcore alike.

<dt>HTML Editor<dd>Basically a text editor on steroids facilitating the writing of HTML source

code by providing a graphical user interface containing buttons and drop-down menus that allow one to insert commonly used snippets of code.

<dt>WYSIWYG Editor<dd>A program which permits the user to create a web page by working 'on top' w

ith the finished product as opposed to working underneath with the HTML source code (WYSIWYG = What You See Is What You Get). Although the easiest to use, WYSIWYG editors quite often produce bloated and junky source code.</dl>

Page 63: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 63/70

Definition list (2/2)

<dt><dd>

Page 64: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 64/70

MORE ABOUT HTML

Page 65: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 65/70

More about HTML tags

Some tags can contain additional information called attributes

Syntax:

<element attribute="value" attribute="value"> content </element>

Example:

<a href="page2.html">Next page</a>

Some tags don't contain content and can be opened and closed in one

tag

Syntax:

<element attribute="value" attribute="value" />

Example:

<br />, <hr />, <br>, <hr>

<img src="bunny.jpg" alt="pic from Easter" />

Note: whether you use the '/' in a self-closing tag is up to you, as long as

you're consistent

Page 66: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 66/70

Generic container: <div> tag

The HTML Content Division element (<div>) is the generic container

for flow content. It has no effect on the content or layout until styled

using CSS.

As a "pure" container, the <div> element does not inherently represent

anything

Note: The <div> element should be used only when no other semantic

element (such as <article> or <nav>) is appropriate.

<div><p>Any kind of content here. Such asparagraphs, tables, images. You name it!</p>

</div>

Page 67: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 67/70

Rules and exceptions

Block vs. inline:

Some block elements can contain only other block elements: <body>, <form>

<p> tags can contain only inline elements and plain text

Some block elements can contain either: <div>, <li>

Some elements are only allowed to contain certain other elements:

<ul> is only allowed to contain <li>

Some elements are only allowed once per document:

<html>

<body>

<head>

<main>

Page 68: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 68/70

Nesting tags

Tags must be correctly nested

A closing tag must match the most recently opened tag

Wrong:

The browser may render it correctly anyway, but it is invalid HTML

Correct:

<p>HTML is <em>really</em>,<strong>REALLY lots of</strong> fun!

</p>

<p>HTML is <em> really, <strong>REALLY </em> lots of</strong>fun!</p>

Page 69: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 69/70

Comments: <!-- ... -->

Comments to document your HTML file or "comment out" text

Useful at top of page and for disabling code

Comments cannot be nested and cannot contain a --

<!-- My web page --><p>Software courses are <!-- NOT --> a lot of fun!</p>

Page 70: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 70/70

Way of representing any Unicode character within a web page:

Complete list of HTML entities

How would you display the text &amp; on a web page?

Special character entities

Character(s) Entity

<> &lt; &gt;

™ © &trade; &copy;

π δ Δ &pi; &delta; &Delta;

" & &quot; &amp;

Page 71: Chapter 2 HTML basics - SKKUmonet.skku.edu/wp-content/uploads/2018/08/Chapter-02... · 2018-09-13 · Create your first page with Atom (1/5) Create a folder on your computer for the

Web Programming Networking Laboratory 71/70

HTML-encoding text

To display this text in a web page:

The special characters should be encoded as follows

&lt;p&gt;&lt;a href=&quot;http://google.com/search?q=marty&amp;ie=utf-8&quot;

&gt;Search Google for Marty

&lt;/a&gt;&lt;/p&gt;