51
Hypertext Markup Language IFI7174.DT – Lesson 1

Ifi7174 lesson1

  • Upload
    sonia

  • View
    8.371

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Ifi7174 lesson1

Hypertext Markup Language

IFI7174.DT – Lesson 1

Page 2: Ifi7174 lesson1

@ Sonia Sousa 2

OutlineHTML

Basic concepts

Basic elements

Text

Lists

Hyperlinks and images

Tables

Forms

2015

Page 3: Ifi7174 lesson1

Concepts

• HTML is – A markup language interpreted by Web browsers– It is “spoken” into 2 different ways…

• CLIENT side – a person (user) perspective

» who access to a Web site.• SERVER side

– data storage perspective » information/data that is stored in a computer (server)

and later is distributed to clients (users)

Page 4: Ifi7174 lesson1

Why?• If we can generate HTML easily• First.... because you need

– Clean code to develop distributed interfaces• Second.... you need

– To have control over the code• What happen if some problem happens?• How to fix it?

– Need to talk with a Professional

• Last… you need confidence and competence– To talk with developers– To be able to

• Create a particular result • Read or reuse the code, and "borrow" the effects.

Dreamweaver or wordpress

Page 5: Ifi7174 lesson1

What HTML does?• HTML defines the structure of the document

– Document• Pages – structure

– Content • multimedia elements

– text, lists, links, images, tables, and forms

• Provide the information needed for – the browser to present the content to the user; and

• define What each element is..– Heading – paragraph – list of items, – a link, – or an image

• This is due by adding markups “< > </>”

Page 6: Ifi7174 lesson1

HTML and HTML5

• Added new semantic elements– HTML

• <head>, <title>, and <body>– HTML5

• Extra elements – <header>, <section>, <footer>, – <aside>, <nav>, <main>, <article>, <figure>

• Removed elements– <frame>, <center>, <dir> or <applet>

Page 7: Ifi7174 lesson1

HTML and XHTML

• XHTML– Is a Extensible HyperText Markup Language– HTML

• Is a HyperText Markup Language

• Helps you to cope with– Different browser technologies– It combines HTML and XML

• XML is EXtensible Markup Language– Designed to describe data– Demands for well-formed code

Page 8: Ifi7174 lesson1

XHTML

• Mandatory – DOCTYPE declaration <!DOCTYPE html>– Structure Attributes

• <html>, <head>, <title>, and <body>– Elements

• Correctly nested• Closed• Lowercase• Values must be Quoted• No minimization attributes

Page 9: Ifi7174 lesson1

Tools to use

• Text editor– Coda 2

• http://www.panic.com/coda/– Notepad++

• https://notepad-plus-plus.org– Any text editor

• Notepad

Page 10: Ifi7174 lesson1

DOCUMENT STRUCTURE

Page 11: Ifi7174 lesson1

Document structure<html>

</html>

<head>

</body>

</head><body>

<h1> Heading of the text </h1>

<p> block <br> of text </p>

<h2>sub Heading </h2>

What the browser show

<!DOCTYPE html>

Page 12: Ifi7174 lesson1

HTML elements

The opening/closing tags – <html> the closing tag is </html>

• a "tag" also can be called an "element”

<! DOCTYPE html> = HTML<html> = initiate page

</html> = end page

<head>

</head>

<body>

</body>

Page 13: Ifi7174 lesson1

HTML elements

<! DOCTYPE html> = HTML

<html> = initiate page

</html> = end page

<head>

</head><title> </title>

<body>

</body>

<meta charset="utf-8"> informs the browser what type of letters the page is written in<meta name="description" content="”> for keywords

contains the code that generates what you see in a browser

Basic tags: text, lists, links, images, tables, and forms

Page 14: Ifi7174 lesson1

HTML EXERCISEStructure document

Page 15: Ifi7174 lesson1

Create your first page

<!DOCTYPE html ><html><head><title>My first web page</title></head>

<body>This is my first web page

</body>

</html>

Page 16: Ifi7174 lesson1

Basic elements

• Text– Heading tags

• <h1></h1>, <h2></h2> … <h6></h6>

– Use them when possible• Google likes this tags.

!!! Google assumes !!! • the contents of <h1> tags are more important than

<h2> tags and so on.

Page 17: Ifi7174 lesson1

Headings tags

<h1>This is heading 1</h1><h2>This is heading 2</h2><h3>This is heading 3</h3><h4>This is heading 4</h4><h5>This is heading 5</h5><h6>This is heading 6</h6>

Page 18: Ifi7174 lesson1

Formating elements

– <p> </p> tag paragraph

– <br /> tag line break

– <div></div> tag for division or a section

– &nbsp; adding a space - non-breaking space.

It is essentially a standard space

– <hr /> horizontal rule

Page 19: Ifi7174 lesson1

Examples<p>Here is a first paragraph of text.</p><p>Here is a second paragraph of text.</p>

<p>Hello<br />You delivered your assignment ontime. <br /><hr />&nbsp; Thanks</p>

<p>This text is not in the center.</p><center><p>This text is in the center.</p></center>

Page 20: Ifi7174 lesson1

HTML EXERCISEformatting

Page 21: Ifi7174 lesson1

<!DOCTYPE html ><html><head><title>My first web page</title></head>

<body><h1>My first web page</h1><h2>What this is</h2><p>A simple page put together using HTML</p><h2>Why this is</h2><p>To learn HTML</p>

</body></html>

Using… headings

Page 22: Ifi7174 lesson1

Lists elements– UL (bullet)

– OL (number)

– DL (definition)

<ul> <li>List item 1</li></ul>

<ol> <li>List item 1</li></ol>

<dl> <dt>Term 1</dt> <dd>Definition of term 1</dd></dl>

Page 23: Ifi7174 lesson1

HTML EXERCISEList data

Page 24: Ifi7174 lesson1

Add this… lists

<body><h1>My first web page</h1><h2>What this is</h2><p>A simple page put together using HTML</p><h2>Why this is</h2>

<ul><li>To learn HTML</li><li>To show off</li><li>Because I've fallen in love with my computer </li></ul>

</body>

Page 25: Ifi7174 lesson1

<ul><li>To learn HTML</li><li>To show off

<ol><li>To my boss</li><li>To my friends</li><li>To my cat</li><li>To the little talking duck in my brain</li>

</ol></li><li>Because I've fallen in love with my computer.</li>

</ul>

Add this… lists

Page 26: Ifi7174 lesson1

Hyperlinks and images• An image

– <img src=”me.png" alt=”Sonia Sousa face” />

• Image path

greeny.cs.tlu.ee

Page2.htmlPage1.htmlIndex.html

print.tiffme.pngheader.jpgimage

root

Folder structure

• Same folder<a href="me.png">Page </a>

• Inside folder<a href="image/me.png">Page </a>

• outside folder<a href="../image/me.png">Page </a>

Page 27: Ifi7174 lesson1

How to add images• In the same folder

• in a subfolder of the page referencing it

• somewhere else on the World Wide Web

• Attributes– alt adding an alternative description.– width and height size frame the image.

<img src=”me.jpg" />

<img src="images/me.jpg"/>

<img src="http://www.tlu.org/tlu.jpg" />

<img src=”../ images/me.jpg"/>

Page 28: Ifi7174 lesson1

Hyperlinks and images• An Hyperlink

– <a href="url">link text</a>– Create a bookmark

• allow readers to jump to specific parts of a Web page– first create the bookmark

» <h2 id=”book”> my books</h2>– Then link it

» <a href=”#book">see my book list</a>

– Target attributes• target="_blank” – open a new window • target=”_self “ - open same window/frame

Page 29: Ifi7174 lesson1

HTML EXERCISEHyperlinks and images

Page 30: Ifi7174 lesson1

<body><p id=”top">To learn HTML</p><h2 id=”top">Where to find the tutorial</h2>

<p><a href="http://www.w3schools.com">HTML examples</a><a href=“list.html">The miracle of links…</a><a href="#top">Go to top</a>

</p></body>

Add this… links

Page 31: Ifi7174 lesson1

HTML EXERCISETables

Page 32: Ifi7174 lesson1

Tables

• Grid format– Think in terms of cells and rows and columns.– Proprieties

• width, height, cellspan, border, valign/align, bgcolor, colspan

<td> one Cells </td>

<td> Cells 1 </td>

<table>

</table>

<tr>

<tr></tr>

</tr>

<td> Cells 2 </td>

table element defines the table.

tr element defines a table row.

td element defines a data cell.

Page 33: Ifi7174 lesson1

Tables

• Proprieties – Width= “763px” define the width of the table– height = “99px” define the height of the table– rowspan= cell span many rows– Border =1 to define a border– valign/align, vertical and horizontal alignment valign="middle" ,

align="center" – bgcolor = “#597172” define the background color of the table– Colspan = "2” = cell span 2 columns

<table width="763px" border="1" align="center" cellpadding="5" cellspacing="3”>

<tr align="center" valign="middle" bgcolor="#597172”>

<td height="99" colspan="2”>

Page 34: Ifi7174 lesson1

HTML EXERCISETables

Page 35: Ifi7174 lesson1

<table ><tr >

<td >Row 1, cell 1</td><td>Row 1, cell 2</td><td>Row 1, cell 3</td>

</tr><tr>

<td>Row 2, cell 1</td><td>Row 2, cell 2</td><td>Row 2, cell 3</td>

</tr><tr>

<td>Row 3, cell 1</td><td>Row 3, cell 2</td><td>Row 3, cell 3</td>

</tr><tr>

<td>Row 4, cell 1</td><td>Row 4, cell 2</td><td>Row 4, cell 3</td>

</tr></table>

Add this… table

Page 36: Ifi7174 lesson1

Forms

• Enables you to collect information from users

</form>

<form >

username >

I vote for

submit

CristianSoniaEdgar

Thank you for your vote

<input type=“” name=“”>

action=“Where you send the information ”method=“GET open information

POST long information or sensitive data”

specifies the HTTP method

Page 37: Ifi7174 lesson1

HTML forms

• Text Input Controls<form>First name: <input type="text” name="first_name" />Description : <br /><textarea rows="5" cols="50" name="description”>

Enter description here…</textarea></form>

Page 38: Ifi7174 lesson1

HTML forms

• Making choices– Checkboxes Controls

<form><input type="checkbox" name="maths" value="on"> Maths<input type="checkbox" name="physics" value="on"> Physics</form>

– Radio Box Controls<form><input type="radio" name="subject" value="maths"> Maths<input type="radio" name="subject" value="physics"> Physics</form>

Page 39: Ifi7174 lesson1

HTML forms

• Select Box Controls<form><select name="dropdown"><option value="Maths" selected>Maths</option><option value="Physics">Physics</option></select></form>

• File Select boxes<form><input type="file" name="fileupload" accept="image/*" /></form>

Page 40: Ifi7174 lesson1

HTML forms

• Submit, Reset and image Buttons<form>

<input type="submit" name="submit" value="Submit" />

<input type="reset" name="reset" value="Reset" />

<input type="button" name="ok" value="OK" />

<input type="image" name="imagebutton" src="/html/images/logo.png" />

</form>

Page 41: Ifi7174 lesson1

HTML forms• Password input

<form >User ID : <input type="text" name="user_id" /><br>Password: <input type="password" name="password" /></form>

Page 42: Ifi7174 lesson1

Example – input text & submit

<form action=”logtext.php" method="get">First name:

<input type="text" name="first_name" value="" maxlength="100" />

<br />Last name: <input type="text" name="last_name" value="" maxlength="100" />

<input type="submit" value="Submit" /></form>

Page 43: Ifi7174 lesson1

Example – input text & submit

Page 44: Ifi7174 lesson1

Add this… form<form action="mailto:[email protected]" method="post">

Name: <br /><input type="text" name="name" value="Type your name” /><br /><br />

<p>Are you:</p><input type="radio" name="areyou" value="male" /> Male<input type="radio" name="areyou" value="female" /> Female

<input type="submit"><input type="reset">

</form>

Page 45: Ifi7174 lesson1

Additional information

Page 46: Ifi7174 lesson1

How to… organize files

• Common file names – Seen as main page by the browser

• "index.html" or "index.htm"

greeny.cs.tlu.ee

Page2.htmlPage1.htmlIndex.html

print.tiffme.pngheader.jpgimages

root

Folder structure

Page 47: Ifi7174 lesson1

Image formats• pixel-based graphics

– Resolution and size influence the quality of the information• Think in pixels: Resolution 72px, 92px

• Format– .gif

• bitmap image format, supports animations, compressed image without degrading the visual quality

– .png • Raster graphics format, created to replace GIF format

• Format .jpg– Images with color (photos)

• Compress image, can lose information

• Vector graphics– represent geometrical primitives

• points, lines, curves, and shapes or polygons– can be magnified infinitely without loss of quality,

Page 48: Ifi7174 lesson1

HTML Color Modes

• Color Names – To be more specific, use Hexadecimal codes

• #FFCC00– Can be shortened to three letters if they're

• the same #FC0– Newer browsers can use

• rgb(0,0,0,0.5);

http://www.color-hex.comhttp://www.w3schools.com/tags/ref_colornames.asphttp://www.w3schools.com/tags/ref_colorpicker.asp

Page 49: Ifi7174 lesson1

HTML tags

http://www.w3schools.com/tags/ref_html_dtd.asp

Page 50: Ifi7174 lesson1

EXERCISE 1 - HTML

Page 51: Ifi7174 lesson1

Frame structure