HTML Fundamentals

Post on 11-Sep-2014

3.334 views 0 download

Tags:

description

 

Transcript of HTML Fundamentals

HTML HTML BasicsBasics

HTML, Text, Images, Tables, HTML, Text, Images, Tables, FormsForms

Doncho MinkovDoncho Minkov

Telerik Mobile Development CourseTelerik Mobile Development Coursemobiledevcourse.telerik.com

Technical TrainerTechnical Trainerhttp://www.minkov.it

Table of ContentsTable of Contents1.1. Introduction to HTMLIntroduction to HTML

How the Web Works?How the Web Works?

What is a Web Page?What is a Web Page?

My First HTML PageMy First HTML Page

Basic Tags: Hyperlinks, Images, Basic Tags: Hyperlinks, Images, FormattingFormatting

Headings and ParagraphsHeadings and Paragraphs

2.2. HTML in DetailsHTML in Details The <!DOCTYPE> DeclarationThe <!DOCTYPE> Declaration

The <head> Section: Title, Meta, Script, The <head> Section: Title, Meta, Script, StyleStyle 2

Table of Contents (2)Table of Contents (2)

The <body> SectionThe <body> Section

Text Styling and Formatting TagsText Styling and Formatting Tags

Hyperlinks: <a>Hyperlinks: <a>

Hyperlinks and SectionsHyperlinks and Sections

Images: <Images: <imgimg>>

Lists: <Lists: <olol>, <>, <ulul> and <dl>> and <dl>

HTML Special CharactersHTML Special Characters

3.3. The <div> and <span> elementsThe <div> and <span> elements

3

How the Web Works?How the Web Works? WWW use classical client / server WWW use classical client / server

architecturearchitecture HTTP is text-based request-response protocolHTTP is text-based request-response protocol

44

Client running Client running a Web a Web

BrowserBrowser

Server running Server running Web Server Web Server

Software (IIS, Software (IIS, Apache, etc.)Apache, etc.)

Server Server responseresponse

HTTPHTTP

HTTPHTTP

What is a Web Page?What is a Web Page? Web pagesWeb pages are text files containing are text files containing

HTMLHTML HTML – HTML – HHyper yper TText ext MMarkup arkup LLanguageanguage

A notation for describingA notation for describing

document structuredocument structure (semantic markup) (semantic markup)

formattingformatting (presentation markup) (presentation markup)

Looks (looked?) like:Looks (looked?) like:

A Microsoft Word documentA Microsoft Word document

The markup tags provide information The markup tags provide information about the page content structureabout the page content structure

5

Creating HTML PagesCreating HTML Pages An HTML file must have an An HTML file must have an ..htmhtm

or or .html.html file extension file extension HTML files can be created with text HTML files can be created with text

editors:editors: NotePad, NotePad ++, PSPadNotePad, NotePad ++, PSPad

Or HTML editors (WYSIWYG Editors):Or HTML editors (WYSIWYG Editors): Microsoft FrontPageMicrosoft FrontPage Macromedia DreamweaverMacromedia Dreamweaver Netscape ComposerNetscape Composer Expression WebExpression Web

6

HTML BasicsHTML BasicsText, Images, Tables, Text, Images, Tables,

FormsForms

HTML StructureHTML Structure HTML is comprised of “HTML is comprised of “elementselements” and ” and

““tagstags”” Begins with Begins with <html><html> and ends with and ends with </html></html>

When writing When writing XHTMLXHTML, must define a , must define a namespacenamespace

Elements (tags) are nested one inside another:Elements (tags) are nested one inside another:

Tags have attributes:Tags have attributes:

HTML describes structure using two main HTML describes structure using two main sections: sections: <head><head> and and <body><body>

8

<html <html xmlns="http://www.w3.org/1999/xhtml">xmlns="http://www.w3.org/1999/xhtml">

<html> <head></head> <body></body> </html><html> <head></head> <body></body> </html>

<img src="logo.jpg" alt="logo" /><img src="logo.jpg" alt="logo" />

HTML Code FormattingHTML Code Formatting The HTML source code should be The HTML source code should be

formatted to increase readability and formatted to increase readability and facilitate debugging.facilitate debugging. Every block element should start on a Every block element should start on a

new line.new line.

Every nested (block) element should be Every nested (block) element should be indented.indented.

Browsers ignore multiple whitespaces Browsers ignore multiple whitespaces in the page source, so formatting is in the page source, so formatting is harmless.harmless.

For performance reasons, For performance reasons, formatting can be sacrificedformatting can be sacrificed 9

First HTML PageFirst HTML Page

10

<!DOCTYPE HTML><!DOCTYPE HTML><html><html> <head><head> <title>My First HTML Page</title><title>My First HTML Page</title> </head></head> <body><body> <p>This is some text...</p><p>This is some text...</p> </body></body></html></html>

test.htmltest.html

<!DOCTYPE HTML><!DOCTYPE HTML><html><html> <head><head> <title>My First HTML Page</title><title>My First HTML Page</title> </head></head> <body><body> <p>This is some text...</p><p>This is some text...</p> </body></body></html></html>

First HTML Page: TagsFirst HTML Page: Tags

11

Opening Opening tagtag

Closing Closing tagtag

An HTML element consists of an opening An HTML element consists of an opening tag, a closing tag and the content inside.tag, a closing tag and the content inside.

<!DOCTYPE HTML><!DOCTYPE HTML><html><html> <head><head> <title>My First HTML Page</title><title>My First HTML Page</title> </head></head> <body><body> <p>This is some text...</p><p>This is some text...</p> </body></body></html></html>

First HTML Page: First HTML Page: HeaderHeader

12

HTML HTML headerheader

<!DOCTYPE HTML><!DOCTYPE HTML><html><html> <head><head> <title>My First HTML Page</title><title>My First HTML Page</title> </head></head> <body><body> <p>This is some text...</p><p>This is some text...</p> </body></body></html></html>

First HTML Page: BodyFirst HTML Page: Body

13

HTML HTML bodybody

Some Simple TagsSome Simple Tags Hyperlink TagsHyperlink Tags

Image TagsImage Tags

Text formatting tagsText formatting tags

14

<a href="http://www.telerik.com/"<a href="http://www.telerik.com/" title="Telerik">Link to Telerik Web title="Telerik">Link to Telerik Web site</a>site</a>

<img src="logo.gif" alt="logo" /><img src="logo.gif" alt="logo" />

This text is <em>emphasized.</em>This text is <em>emphasized.</em><br />new line<br /><br />new line<br />This one is <strong>more This one is <strong>more emphasized.</strong>emphasized.</strong>

Some Simple Tags – Some Simple Tags – ExampleExample

15

<!DOCTYPE HTML><!DOCTYPE HTML><html><html><head><head> <title><title>Simple Tags Demo</title>Simple Tags Demo</title></head></head><body><body><a href="http://www.telerik.com/" title=<a href="http://www.telerik.com/" title= "Telerik site">This is a link.</a>"Telerik site">This is a link.</a><br /><br /><img src="logo.gif" alt="logo" /><img src="logo.gif" alt="logo" /><br /><br /><strong>Bold</strong> and <em>italic</em> <strong>Bold</strong> and <em>italic</em> text.text.</body></body></html></html>

some-tags.htmlsome-tags.html

Some Simple Tags – Some Simple Tags – Example (2)Example (2)

16

<!DOCTYPE HTML><!DOCTYPE HTML><html><html><head><head> <title><title>Simple Tags Demo</title>Simple Tags Demo</title></head></head><body><body><a href="http://www.telerik.com/" title=<a href="http://www.telerik.com/" title= "Telerik site">This is a link.</a>"Telerik site">This is a link.</a><br /><br /><img src="logo.gif" alt="logo" /><img src="logo.gif" alt="logo" /><br /><br /><strong>Bold</strong> and <em>italic</em> text.<strong>Bold</strong> and <em>italic</em> text.</body></body></html></html>

some-tags.htmlsome-tags.html

Some HTML TagsSome HTML TagsLive DemoLive Demo

Tags AttributesTags Attributes Tags can have Tags can have attributesattributes

Attributes specify properties and behaviorAttributes specify properties and behavior Example:Example:

Few attributes can apply to every Few attributes can apply to every element:element: idid, , stylestyle, , classclass, , titletitle

The The idid is unique in the document is unique in the document

Content of Content of titletitle attribute is displayed as attribute is displayed as hint when the element is hovered with the hint when the element is hovered with the mousemouse

Some elements have obligatory attributesSome elements have obligatory attributes18

<img src="logo.gif" alt="logo" /><img src="logo.gif" alt="logo" />

Attribute Attribute altalt with with value "value "logologo""

Headings and Headings and ParagraphsParagraphs

Heading Tags (h1 – h6)Heading Tags (h1 – h6)

Paragraph TagsParagraph Tags

Sections: Sections: divdiv and and spanspan

19

<p>This is my first paragraph</p><p>This is my first paragraph</p><p>This is my second paragraph</p><p>This is my second paragraph</p>

<h1>Heading 1</h1><h1>Heading 1</h1><h2>Sub heading 2</h2><h2>Sub heading 2</h2><h3>Sub heading 3</h3><h3>Sub heading 3</h3>

<div style="background: skyblue;"><div style="background: skyblue;"> This is a div</div>This is a div</div>

Headings and Headings and Paragraphs – Example Paragraphs – Example

20

<!DOCTYPE HTML><!DOCTYPE HTML><html><html> <head><title>Headings and <head><title>Headings and paragraphs</title></head>paragraphs</title></head> <body><body> <h1>Heading 1</h1><h1>Heading 1</h1> <h2>Sub heading 2</h2><h2>Sub heading 2</h2> <h3>Sub heading 3</h3><h3>Sub heading 3</h3>

<p>This is my first paragraph</p><p>This is my first paragraph</p> <p>This is my second paragraph</p><p>This is my second paragraph</p>

<div style="background:skyblue"><div style="background:skyblue"> This is a div</div>This is a div</div> </body></body></html></html>

headings.htmlheadings.html

<!DOCTYPE HTML><!DOCTYPE HTML><html><html> <head><title>Headings and <head><title>Headings and paragraphs</title></head>paragraphs</title></head> <body><body> <h1>Heading 1</h1><h1>Heading 1</h1> <h2>Sub heading 2</h2><h2>Sub heading 2</h2> <h3>Sub heading 3</h3><h3>Sub heading 3</h3>

<p>This is my first paragraph</p><p>This is my first paragraph</p> <p>This is my second paragraph</p><p>This is my second paragraph</p>

<div style="background:skyblue"><div style="background:skyblue"> This is a div</div>This is a div</div> </body></body></html></html>

Headings and Headings and Paragraphs – Example Paragraphs – Example

(2)(2)

21

headings.htmlheadings.html

Headings and Headings and ParagraphsParagraphs

Live DemoLive Demo

Introduction to HTMLIntroduction to HTMLHTML Document Structure in DepthHTML Document Structure in Depth

PrefacePreface It is important to have the correct It is important to have the correct

vision and attitude towards HTMLvision and attitude towards HTML HTML is only about structure, not HTML is only about structure, not

appearanceappearance

Browsers tolerate invalid HTML Browsers tolerate invalid HTML code and parse errors – you should code and parse errors – you should notnot

Always think about semanticsAlways think about semantics

24

The The <<!!DOCTYPE>DOCTYPE> DeclarationDeclaration

HTML documents must start with a HTML documents must start with a document type definition (DTD)document type definition (DTD)

It tells web browsers what type is the It tells web browsers what type is the served codeserved code

Possible versions: HTML 4.01, XHTML 1.0 Possible versions: HTML 4.01, XHTML 1.0 (Transitional or Strict), XHTML 1.1, HTML (Transitional or Strict), XHTML 1.1, HTML 55

Example:Example:

See See http://w3.org/QA/2002/04/valid-dtd-list.html for a list of possible for a list of possible doctypesdoctypes

25

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">transitional.dtd">

HTML vs. XHTMLHTML vs. XHTML XHTML is more strict than HTMLXHTML is more strict than HTML

Tags and attribute names must be Tags and attribute names must be in lowercasein lowercase

All tags must be closed (All tags must be closed (<<brbr/>/>, , <<imgimg/>/>) while HTML allows ) while HTML allows <<brbr>> and and <img><img> and implies missing closing and implies missing closing tags tags (<p>par1 <p>par2(<p>par1 <p>par2))

XHTML allows only one root XHTML allows only one root <html><html> element (HTML allows more than element (HTML allows more than one)one)

26

XHTML vs. HTML (2)XHTML vs. HTML (2) Many element attributes are Many element attributes are

deprecated in XHTML, most are deprecated in XHTML, most are moved to CSS moved to CSS

Attribute minimization is forbidden, Attribute minimization is forbidden, e.g.e.g.

Note: Web browsers load XHTML Note: Web browsers load XHTML faster than HTML and valid code faster than HTML and valid code faster than invalid!faster than invalid! 27

<input type="checkbox" checked><input type="checkbox" checked>

<input type="checkbox" <input type="checkbox" checked="checked" />checked="checked" />

The The <head><head> Section Section Contains information that doesn’t Contains information that doesn’t

show directly on the viewable pageshow directly on the viewable page Starts after the Starts after the <!<!doctypedoctype>> declaration declaration Begins with Begins with <head><head> and ends with and ends with </head></head>

Contains mandatory single Contains mandatory single <title><title> tag tag Can contain some other tags, e.g.Can contain some other tags, e.g.

<meta><meta> <script><script> <style><style> <!–- comments --><!–- comments -->

28

<head> Section: <head> Section: <title> tag<title> tag

Title should be placed between Title should be placed between <head><head> and and </head></head> tags tags

Used to specify a title in the window Used to specify a title in the window titlebartitlebar

Search engines and people rely on titlesSearch engines and people rely on titles29

<title>Telerik Academy – Winter Season <title>Telerik Academy – Winter Season 2009/2010 </title>2009/2010 </title>

<head> Section: <head> Section: <meta><meta>

Meta tags additionally describe the Meta tags additionally describe the content contained within the pagecontent contained within the page

30

<meta name="description" content="HTML <meta name="description" content="HTML tutorial" />tutorial" />

<meta name="keywords" content="html, web <meta name="keywords" content="html, web design, styles" />design, styles" /> <meta name="author" content="Chris Brewer" <meta name="author" content="Chris Brewer" /> />

<meta http-equiv="refresh" content="5; <meta http-equiv="refresh" content="5; url=http://www.telerik.com" />url=http://www.telerik.com" />

<head> Section: <head> Section: <script><script>

The The <script><script> element is used to embed element is used to embed scripts into an HTML documentscripts into an HTML document Script are executed in the client's Web Script are executed in the client's Web

browserbrowser

Scripts can live in the Scripts can live in the <head><head> and in the and in the <body><body> sections sections

Supported client-side scripting Supported client-side scripting languages:languages: JavaScriptJavaScript (it is not (it is not JavaJava!)!)

VBScriptVBScript

JScriptJScript 31

The <script> Tag – The <script> Tag – ExampleExample

32

<!DOCTYPE HTML><!DOCTYPE HTML><html><html> <head><head> <title>JavaScript Example</title><title>JavaScript Example</title> <script type="text/javascript"><script type="text/javascript"> function sayHello() {function sayHello() { document.write("<p>Hello document.write("<p>Hello World!<\/p>");World!<\/p>"); }} </script></script> </head></head> <body><body> <script type=<script type= "text/javascript">"text/javascript"> sayHello();sayHello(); </script></script> </body></body></html></html>

scripts-scripts-

example.htmlexample.html

Using ScriptsUsing ScriptsLive DemoLive Demo

<head> Section: <head> Section: <style><style>

The The <style><style> element embeds element embeds formatting information (CSS styles) formatting information (CSS styles) into an HTML pageinto an HTML page

34

<html><html> <head><head> <style type="text/css"><style type="text/css"> p { font-size: 12pt; line-height: 12pt; }p { font-size: 12pt; line-height: 12pt; } p:first-letter { font-size: 200%; }p:first-letter { font-size: 200%; } span { text-transform: uppercase; }span { text-transform: uppercase; } </style></style> </head></head> <body><body> <p>Styles demo.<br /><p>Styles demo.<br /> <span>Test uppercase</span>.<span>Test uppercase</span>. </p></p> </body></body></html></html>

style-example.htmlstyle-example.html

Embedding CSS Embedding CSS StylesStylesLive DemoLive Demo

Comments: <!-- --> TagComments: <!-- --> Tag Comments can exist anywhere Comments can exist anywhere

between the between the <html></html><html></html> tagstags Comments start with Comments start with <!--<!-- and end and end

with with -->-->

36

<!–- Telerik Logo (a JPG file) --><!–- Telerik Logo (a JPG file) --><img src="logo.jpg" alt=“Telerik Logo"><img src="logo.jpg" alt=“Telerik Logo"><!–- Hyperlink to the web site --><!–- Hyperlink to the web site --><a href="http://telerik.com/">Telerik</a><a href="http://telerik.com/">Telerik</a><!–- Show the news table --><!–- Show the news table --><table class="newstable"><table class="newstable">......

<body> Section: <body> Section: IntroductionIntroduction

The The <body><body> section describes the section describes the viewable portion of the pageviewable portion of the page

Starts after the Starts after the <head><head> </head></head> sectionsection

Begins with Begins with <body><body> and ends with and ends with </body></body>

37

<html><html> <head><title>Test page</title></head><head><title>Test page</title></head> <body><body> <!-- This is the Web page body --><!-- This is the Web page body --> </body></body></html></html>

Text FormattingText Formatting Text formatting tags modify the Text formatting tags modify the

text between the opening tag and text between the opening tag and the closing tagthe closing tag Ex. Ex. <b>Hello</b><b>Hello</b> makes “Hello” bold makes “Hello” bold

38

Text Formatting – Text Formatting – ExampleExample

39

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">transitional.dtd"><html><html> <head><head> <title>Page Title</title><title>Page Title</title> </head></head> <body><body> <h1>Notice</h1><h1>Notice</h1> <p>This is a <em>sample</em> Web page.</p><p>This is a <em>sample</em> Web page.</p> <p><pre>Next paragraph:<p><pre>Next paragraph: preformatted.</pre></p>preformatted.</pre></p> <h2>More Info</h2><h2>More Info</h2> <p>Specifically, we’re using XHMTL 1.0 transitional.<br <p>Specifically, we’re using XHMTL 1.0 transitional.<br />/> Next line.</p>Next line.</p> </body></body></html></html>

text-text-

formatting.htmlformatting.html

Text Formatting – Text Formatting – Example (2)Example (2)

40

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">transitional.dtd"><html><html> <head><head> <title>Page Title</title><title>Page Title</title> </head></head> <body><body> <h1>Notice</h1><h1>Notice</h1> <p>This is a <em>sample</em> Web page.</p><p>This is a <em>sample</em> Web page.</p> <p><pre>Next paragraph:<p><pre>Next paragraph: preformatted.</pre></p>preformatted.</pre></p> <h2>More Info</h2><h2>More Info</h2> <p>Specifically, we’re using XHMTL 1.0 transitional.<br <p>Specifically, we’re using XHMTL 1.0 transitional.<br />/> Next line.</p>Next line.</p> </body></body></html></html>

text-text-

formatting.htmlformatting.html

Text Text FormattingFormatting

Live DemoLive Demo

Hyperlinks: <a> TagHyperlinks: <a> Tag Link to a document called Link to a document called form.htmlform.html

on the same server in the same on the same server in the same directory:directory:

Link to a document called Link to a document called parent.htmlparent.html on the same server in the parent on the same server in the parent directory:directory:

Link to a document called Link to a document called cat.htmlcat.html on on the same server in the subdirectory the same server in the subdirectory stuffstuff:: 42

<a href="form.html">Fill Our Form</a><a href="form.html">Fill Our Form</a>

<a href="../parent.html">Parent</a><a href="../parent.html">Parent</a>

<a href="stuff/cat.html">Catalog</a><a href="stuff/cat.html">Catalog</a>

Hyperlinks: <a> Tag (2)Hyperlinks: <a> Tag (2) Link to an external Web site:Link to an external Web site:

Always use a full URL, including Always use a full URL, including ""http://http://", not just ", not just ""www.somesite.comwww.somesite.com""

Using the Using the target="_blank"target="_blank" attribute attribute opens the link in a new windowopens the link in a new window

Link to an e-mail address:Link to an e-mail address:

43

<a href="http://www.devbg.org" <a href="http://www.devbg.org" target="_blank">BASD</a>target="_blank">BASD</a>

<a href="mailto:bugs@example.com?<a href="mailto:bugs@example.com?subject=Bug+Report">subject=Bug+Report">Please report bugs here (by e-mail only)</a>Please report bugs here (by e-mail only)</a>

Hyperlinks: <a> Tag (3)Hyperlinks: <a> Tag (3) Link to a document called Link to a document called apply-apply-now.htmlnow.html On the same server, in same directoryOn the same server, in same directory

Using an image as a link button:Using an image as a link button:

Link to a document called Link to a document called index.htmlindex.html On the same serverOn the same server, , in the in the

subdirectory subdirectory englishenglish of the parent of the parent directory:directory:

44

<a href="apply-now.html"><img<a href="apply-now.html"><img src="apply-now-button.jpg" /></a>src="apply-now-button.jpg" /></a>

<a href="../english/index.html">Switch to <a href="../english/index.html">Switch to English version</a>English version</a>

Hyperlinks and Hyperlinks and SectionsSections

Link to another location in the same Link to another location in the same document:document:

Link to a specific location in another Link to a specific location in another document:document:

45

<a href="#section1">Go to Introduction</a><a href="#section1">Go to Introduction</a>......<h2 id="section1">Introduction</h2><h2 id="section1">Introduction</h2>

<a href="chapter3.html#section3.1.1">Go to <a href="chapter3.html#section3.1.1">Go to Section 3.1.1</a>Section 3.1.1</a>

<!–- In chapter3.html --><!–- In chapter3.html -->......<div id="section3.1.1"><div id="section3.1.1"> <h3>3.1.1. Technical Background</h3><h3>3.1.1. Technical Background</h3></div></div>

Hyperlinks – ExampleHyperlinks – Example

46

<a href="form.html">Fill Our Form</a> <br /><a href="form.html">Fill Our Form</a> <br /><a href="../parent.html">Parent</a> <br /><a href="../parent.html">Parent</a> <br /><a href="stuff/cat.html">Catalog</a> <br /><a href="stuff/cat.html">Catalog</a> <br /><a href="http://www.devbg.org" <a href="http://www.devbg.org" target="_blank">BASD</a> <br />target="_blank">BASD</a> <br /><a href="mailto:bugs@example.com?subject=Bug <a href="mailto:bugs@example.com?subject=Bug Report">Please report bugs here (by e-mail Report">Please report bugs here (by e-mail only)</a>only)</a><br /><br /><a href="apply-now.html"><img src="apply-now-<a href="apply-now.html"><img src="apply-now-button.jpg” /></a> <br />button.jpg” /></a> <br /><a href="../english/index.html">Switch to English <a href="../english/index.html">Switch to English version</a> <br />version</a> <br />

hyperlinks.htmlhyperlinks.html

<a href="form.html">Fill Our Form</a> <br /><a href="form.html">Fill Our Form</a> <br /><a href="../parent.html">Parent</a> <br /><a href="../parent.html">Parent</a> <br /><a href="stuff/cat.html">Catalog</a> <br /><a href="stuff/cat.html">Catalog</a> <br /><a href="http://www.devbg.org" <a href="http://www.devbg.org" target="_blank">BASD</a> <br />target="_blank">BASD</a> <br /><a href="mailto:bugs@example.com?subject=Bug <a href="mailto:bugs@example.com?subject=Bug Report">Please report bugs here (by e-mail Report">Please report bugs here (by e-mail only)</a>only)</a><br /><br /><a href="apply-now.html"><img src="apply-now-<a href="apply-now.html"><img src="apply-now-button.jpg” /></a> <br />button.jpg” /></a> <br /><a href="../english/index.html">Switch to English <a href="../english/index.html">Switch to English version</a> <br />version</a> <br />

hyperlinks.htmlhyperlinks.html

Hyperlinks – Example Hyperlinks – Example (2)(2)

47

HyperlinksHyperlinksLive DemoLive Demo

Links to the Same Links to the Same Document – Example Document – Example

49

<h1>Table of Contents</h1><h1>Table of Contents</h1>

<p><a href="#section1">Introduction</a><br /><p><a href="#section1">Introduction</a><br /><a href="#section2">Some background</A><br /><a href="#section2">Some background</A><br /><a href="#section2.1">Project History</a><br /><a href="#section2.1">Project History</a><br />...the rest of the table of contents......the rest of the table of contents...

<!-- The document text follows here --><!-- The document text follows here -->

<h2 id="section1">Introduction</h2><h2 id="section1">Introduction</h2>... Section 1 follows here ...... Section 1 follows here ...<h2 id="section2">Some background</h2><h2 id="section2">Some background</h2>... Section 2 follows here ...... Section 2 follows here ...<h3 id="section2.1">Project History</h3><h3 id="section2.1">Project History</h3>... Section 2.1 follows here ...... Section 2.1 follows here ...

links-to-same-links-to-same-document.htmldocument.html

Links to the Same Links to the Same Document – Example (2) Document – Example (2)

50

<h1>Table of Contents</h1><h1>Table of Contents</h1>

<p><a href="#section1">Introduction</a><br /><p><a href="#section1">Introduction</a><br /><a href="#section2">Some background</A><br /><a href="#section2">Some background</A><br /><a href="#section2.1">Project History</a><br /><a href="#section2.1">Project History</a><br />...the rest of the table of contents......the rest of the table of contents...

<!-- The document text follows here --><!-- The document text follows here -->

<h2 id="section1">Introduction</h2><h2 id="section1">Introduction</h2>... Section 1 follows here ...... Section 1 follows here ...<h2 id="section2">Some background</h2><h2 id="section2">Some background</h2>... Section 2 follows here ...... Section 2 follows here ...<h3 id="section2.1">Project History</h3><h3 id="section2.1">Project History</h3>... Section 2.1 follows here ...... Section 2.1 follows here ...

links-to-same-links-to-same-document.htmldocument.html

Links to the Same Links to the Same DocumentDocument

Live DemoLive Demo

Inserting an image with Inserting an image with <img><img> tag: tag:

Image attributes:Image attributes:

Example:Example:

Images: Images: <img><img> tag tag

src src Location of image fileLocation of image file (relative or absolute) (relative or absolute)

altalt Substitute text for displaySubstitute text for display (e.g. in text mode) (e.g. in text mode)

height height Number of pixels of the heightNumber of pixels of the height

width width Number of pixels of the widthNumber of pixels of the width

border border Size of border, 0 for no borderSize of border, 0 for no border

<img src="/img/basd-logo.png"><img src="/img/basd-logo.png">

<img src="./php.png" alt="PHP Logo" /><img src="./php.png" alt="PHP Logo" />52

Miscellaneous TagsMiscellaneous Tags <hr<hr />/>: Draws a horizontal rule : Draws a horizontal rule

(line):(line):

<center></center><center></center>: Deprecated!: Deprecated!

<font></font><font></font>: Deprecated!: Deprecated!

53

<hr size="5" width="70%" /><hr size="5" width="70%" />

<center>Hello World!</center><center>Hello World!</center>

<font size="3" color="blue">Font3</font><font size="3" color="blue">Font3</font><font size="+4" color="blue">Font+4</font><font size="+4" color="blue">Font+4</font>

Miscellaneous Tags – Miscellaneous Tags – ExampleExample

54

<html><html> <head><head> <title>Miscellaneous Tags Example</title><title>Miscellaneous Tags Example</title> </head></head> <body><body> <hr size="5" width="70%" /><hr size="5" width="70%" /> <center>Hello World!</center><center>Hello World!</center> <font size="3" color="blue">Font3</font><font size="3" color="blue">Font3</font> <font size="+4" color="blue">Font+4</font><font size="+4" color="blue">Font+4</font> </body></body></html></html>

misc.htmlmisc.html

Miscellaneous Miscellaneous TagsTags

Live DemoLive Demo

a. Appleb. Orangec. Grapefruit

Ordered Lists: Ordered Lists: <ol><ol> Tag Tag Create an Create an OOrdered rdered LList using ist using <ol></ol><ol></ol>::

Attribute values for Attribute values for typetype are are 11, , AA, , aa, , II, , or or ii

56

1. Apple2. Orange3. Grapefruit

A. AppleB. OrangeC. Grapefruit

I. AppleII. OrangeIII. Grapefruit

i. Appleii. Orangeiii. Grapefruit

<ol type="1"><ol type="1"> <li>Apple</li><li>Apple</li> <li>Orange</li><li>Orange</li> <li>Grapefruit</li><li>Grapefruit</li></ol></ol>

Unordered Lists: Unordered Lists: <<uul>l> TagTag

Create an Create an UUnordered nordered LList using ist using <ul></ul><ul></ul>::

Attribute values for Attribute values for typetype are: are: discdisc, , circlecircle or or squaresquare

57

• Apple

• Orange

• Pear

o Apple

o Orange

o Pear

Apple

Orange

Pear

<ul type="disk"><ul type="disk"> <li>Apple</li><li>Apple</li> <li>Orange</li><li>Orange</li> <li>Grapefruit</li><li>Grapefruit</li></ul></ul>

Definition lists: <dl> Definition lists: <dl> tagtag

Create definition lists using Create definition lists using <dl><dl> Pairs of text and associated Pairs of text and associated

definition; text is in definition; text is in <dt><dt> tag, tag, definition in definition in <dd><dd> tag tag

Renders without bulletsRenders without bullets

Definition is indentedDefinition is indented 58

<dl><dl><dt>HTML</dt><dt>HTML</dt><dd>A markup language …</dd><dd>A markup language …</dd><dt>CSS</dt><dt>CSS</dt><dd>Language used to …</dd><dd>Language used to …</dd>

</dl></dl>

Lists – ExampleLists – Example

59

<ol type="1"><ol type="1"> <li>Apple</li><li>Apple</li> <li>Orange</li><li>Orange</li> <li>Grapefruit</li><li>Grapefruit</li></ol></ol>

<ul type="disc"><ul type="disc"> <li>Apple</li><li>Apple</li> <li>Orange</li><li>Orange</li> <li>Grapefruit</li><li>Grapefruit</li></ul></ul>

<dl><dl> <dt>HTML</dt><dt>HTML</dt> <dd>A markup lang…</dd><dd>A markup lang…</dd></dl></dl>

lists.htmllists.html

Creating Creating ListsLists

Live DemoLive Demo

HTML Special HTML Special CharactersCharacters

££&pound;&pound;British PoundBritish Pound

€€&#8364;&#8364;EuroEuro

""&quot;&quot;Quotation MarkQuotation Mark

¥¥&yen;&yen;Japanese YenJapanese Yen

——&mdash;&mdash;Em DashEm Dash

&nbsp;&nbsp;Non-breaking SpaceNon-breaking Space

&&&amp;&amp;AmpersandAmpersand

>>&gt;&gt;Greater ThanGreater Than

<<&lt;&lt;Less ThanLess Than

™™&trade;&trade;Trademark SignTrademark Sign

®®&reg;&reg;Registered Trademark Registered Trademark SignSign

©©&copy;&copy;Copyright SignCopyright Sign

SymbolSymbolHTML HTML EntityEntitySymbol NameSymbol Name

61

Special Characters – Special Characters – ExampleExample

62

<p>[&gt;&gt;&nbsp;&nbsp;Welcome<p>[&gt;&gt;&nbsp;&nbsp;Welcome &nbsp;&nbsp;&lt;&lt;]</p>&nbsp;&nbsp;&lt;&lt;]</p> <p>&#9658;I have following cards:<p>&#9658;I have following cards: A&#9827;, K&#9830; and 9&#9829;.</p>A&#9827;, K&#9830; and 9&#9829;.</p> <p>&#9658;I prefer hard rock &#9835;<p>&#9658;I prefer hard rock &#9835; music &#9835;</p>music &#9835;</p> <p>&copy; 2006 by Svetlin Nakov &amp; his <p>&copy; 2006 by Svetlin Nakov &amp; his team</p>team</p> <p>Telerik Academy™</p><p>Telerik Academy™</p>

special-special-

chars.htmlchars.html

Special Chars – Example Special Chars – Example (2)(2)

63

<p>[&gt;&gt;&nbsp;&nbsp;Welcome<p>[&gt;&gt;&nbsp;&nbsp;Welcome &nbsp;&nbsp;&lt;&lt;]</p>&nbsp;&nbsp;&lt;&lt;]</p> <p>&#9658;I have following cards:<p>&#9658;I have following cards: A&#9827;, K&#9830; and 9&#9829;.</p>A&#9827;, K&#9830; and 9&#9829;.</p> <p>&#9658;I prefer hard rock &#9835;<p>&#9658;I prefer hard rock &#9835; music &#9835;</p>music &#9835;</p> <p>&copy; 2006 by Svetlin Nakov &amp; his <p>&copy; 2006 by Svetlin Nakov &amp; his team</p>team</p> <p>Telerik Academy™</p><p>Telerik Academy™</p>

special-special-

chars.htmlchars.html

HTML Special HTML Special CharactersCharacters

Live DemoLive Demo

Using Using <DIV><DIV> and and <SPAN><SPAN> Block and Block and Inline ElementsInline Elements

Block and Inline Block and Inline ElementsElements

Block elements Block elements add a line break add a line break before and after them, and expand before and after them, and expand to 100% widthto 100% width <div>, <p>, <h1>, <ul><div>, <p>, <h1>, <ul> are block are block

elementselements Inline elements Inline elements don’t break the don’t break the

text before and after themtext before and after them <span>, <a>, <em> <span>, <a>, <em> are inline are inline

elementselements http://www.w3.org/TR/CSS2/visuren.html#block-boxes 66

The <div> TagThe <div> Tag <div><div> creates logical divisions creates logical divisions

within a pagewithin a page

Block style elementBlock style element

Used with CSSUsed with CSS

Example:Example:

67

<div style="font-size:24px; color:red">DIV <div style="font-size:24px; color:red">DIV example</div>example</div>

<p>This one is <span style="color:red; font-<p>This one is <span style="color:red; font-weight:bold">only a test</span>.</p>weight:bold">only a test</span>.</p>

div-and-div-and-

span.htmlspan.html

<DIV><DIV>Live DemoLive Demo

The <span> TagThe <span> Tag Inline style elementInline style element Useful for modifying a specific Useful for modifying a specific

portion of text portion of text Don't create a separate areaDon't create a separate area

(paragraph) in the document (paragraph) in the document Makes sense only with some CSSMakes sense only with some CSS

69

<p>This one is <span style="color:red; font-<p>This one is <span style="color:red; font-weight:bold">only a test</span>.</p>weight:bold">only a test</span>.</p>

<p>This one is another <span style="font-<p>This one is another <span style="font-size:32px; font-weight:bold">TEST</span>.</p>size:32px; font-weight:bold">TEST</span>.</p>

span.htmlspan.html

<SPAN><SPAN>Live DemoLive Demo

HTML Tags IndexHTML Tags Index http://www.w3.org/TR/html4/index/elements.html

http://www.htmldog.com/reference/htmltags/

71

HTML BasicsHTML Basics

Questions?Questions?

http://academy.telerik.com

ExercisesExercises

1.1. Write an HTML page like the following:Write an HTML page like the following:

* Use headings and divs* Use headings and divs

73

Exercises (2)Exercises (2)2.2. Write an HTML page like the following:Write an HTML page like the following:

3.3. Write an HTML page looking like the PNG Write an HTML page looking like the PNG file named file named 3.Introduction.PNG.3.Introduction.PNG. Using the Using the <a><a> tag add anchors to the corresponding tag add anchors to the corresponding sections in the same page.sections in the same page. 74

Exercises (3)Exercises (3)4.4. Create an user profile Create an user profile

Web page Web page Profile.htmlProfile.html, , friends page named friends page named Friends.htmlFriends.html and info and info page named page named Info.htmlInfo.html. . Link them to one Link them to one another using another using <a> <a> tagtag

75

Exercises (4)Exercises (4)

76

5.5. Create a Web site like the following:Create a Web site like the following:

See the image See the image InetJava-site.pngInetJava-site.png..