topic 02 : introduction to (x)html

37
Topic 2: Introduction to (X)HTML Er. Pradip Kharbuja

Post on 11-Sep-2014

363 views

Category:

Education


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Topic 02 : Introduction to (X)HTML

Topic 2: Introduction to (X)HTML

Er. Pradip Kharbuja

Page 2: Topic 02 : Introduction to (X)HTML

HTML

• Hyper Text Markup language.

• Markup refers to the sequence of characters that describes the document’s structure and how the file should look when it is printed or displayed.

• HTML does not define what a page looks like! For that we have CSS.

• Extension is html or htm.

• Write code in any text editor (e.g. Notepad, Notepad++, Dream weaver, etc) and save as filename.html/htm

• Initially, html deals with only text but now multimedia too.

• Html is not a case sensitive.

Page 3: Topic 02 : Introduction to (X)HTML

HTML Tags

• The markup indicators are often called "tags."

• Beings with an open angle bracket (<) and ends with close angle bracket (>).

• e.g. <html>, <head>, <br/>, <table>, etc.

• Two types: -

1. Singular Tag or Empty Elements• Tag that comes alone, no closing tag.

• It doesn’t contain any content.

• e.g <br />, <hr />, <img />, etc.

Page 4: Topic 02 : Introduction to (X)HTML

HTML Tags

2. Paired Tag• Tag that needs opening and closing tag.

• e.g.

• <h1> is opening tag. </h1> is closing tag. “Welcome to HTML” is content.

• Some paired tags are :

• <body> , <table>, <tr>, <b> , etc.

• Last In First Out (LIFO) concept

• i.e. last tag should be closed first.

Page 5: Topic 02 : Introduction to (X)HTML

My First HTML

Page 6: Topic 02 : Introduction to (X)HTML

My First HTML - Output

Page 7: Topic 02 : Introduction to (X)HTML

HTML Attributes

• Additional information written immediately after the html tag separated by space is known as attributes (properties) of tag.

• Attributes are written in following way : .

• e.g:-

Page 8: Topic 02 : Introduction to (X)HTML

HTML Section

1. Head Section

i. Title

ii. Style

iii. Script

iv. Meta

2. Body Section

• The body of HTML document contains all content that is displayed in a browser: text, images, lists, tables, and more.

Page 9: Topic 02 : Introduction to (X)HTML

Text Styles

1. Bold <b>...............</b> / <strong>..............</strong>

2. Italic <i>................</i> / <em>..................</em>

3. Underlined <u>..................</u>

4. Superscript <sup> ………</sup>

5. Subscript <sub> …………</sub>

Page 10: Topic 02 : Introduction to (X)HTML

Text Styles

Page 11: Topic 02 : Introduction to (X)HTML

Text Styles - Output

Page 12: Topic 02 : Introduction to (X)HTML

Line Breaks (<br/>)

Page 13: Topic 02 : Introduction to (X)HTML

Text Elements

• There are two categories of text element:

1. Block elements

• For marking up large blocks of content such as headings and paragraphs

• E.g. <h1>, <h2>, <p>, <div>, etc.

2. Inline elements

• For marking up individual words or phrases

• E.g. <strong>, <em>, <span>, etc.

Page 14: Topic 02 : Introduction to (X)HTML

Block Element - Paragraph (<p>… </p>)

• When a browser displays a paragraph, it adds a new line before the paragraph.

• Paragraphs should not be nested inside other paragraphs

Page 15: Topic 02 : Introduction to (X)HTML

Paragraph Break - Output

Page 16: Topic 02 : Introduction to (X)HTML

Block Elements - Heading

• There are 6 different levels of headings. <h1> to <h6>.

• The highest level header format is <h1> and the lowest is <h6> i.e:- font size decreases.

• All the styles appeared in bold face.

• Headings shouldn’t be nested inside other headings.

Page 17: Topic 02 : Introduction to (X)HTML

Block Elements - Heading

Page 18: Topic 02 : Introduction to (X)HTML

Inline Elements

• Inline elements are used to markup small portions of text.

• Inline elements must always be nested inside a block level element.

Page 19: Topic 02 : Introduction to (X)HTML

‘Physical Style’ tags

• HTML has <font> tag to style the text.

• We can specify color, typeface, size of the text.

• This tag has been ‘deprecated’:

• Will still work in many browsers

• No longer in use

• We shouldn’t use them in our pages!

Page 20: Topic 02 : Introduction to (X)HTML

Inserting Spaces

• Browsers will always truncate spaces in HTML pages.

• If you write 10 spaces in your text, the browser will remove 9 of them, before displaying the page.

• To add spaces to your text, you can use the &nbsp; character entity.

Page 21: Topic 02 : Introduction to (X)HTML

Character Entities

Result Description Entity Name

< less than &lt;

> greater than &gt;

& ampersand &amp;

¢ cent &cent;

£ pound &pound;

€ euro &euro;

© copyright &copy;

® registered trademark &reg;

™ trademark &trade;

Page 22: Topic 02 : Introduction to (X)HTML

List

1. Unordered List

• Bulleting

• <ul> … </ul>

• each list starts with <li> and ends with </li>

• Attribute of <ul> tag is : type. Its values can be circle, square, disc.

Page 23: Topic 02 : Introduction to (X)HTML

List

2. Ordered List

• Numbering

• <ol>…</ol>

• each list starts with <li> and ends with </li>

• Attribute of <ol> tag are

a. type. It possible values are ("1", "A", "i", "I", "a")

b. start

Page 24: Topic 02 : Introduction to (X)HTML

List

2. Ordered List

Page 25: Topic 02 : Introduction to (X)HTML

Nesting the List

Page 26: Topic 02 : Introduction to (X)HTML

Task #01

Last Date to Submit :

18th Jan, 2014

Send email @

[email protected]

with your name and batch

http://www.pradipkharbuja.com.np/blog/

Page 27: Topic 02 : Introduction to (X)HTML

List

3. Definition List• The <dl> tags define the start and end of the list.

• The <dt> element specifies the definition term.

• The <dd> element specifies the actual definition.

Page 28: Topic 02 : Introduction to (X)HTML

Document Structure

Four parts in document structure : 1. document type declaration2. the root element3. the head section and 4. the body section.

Page 29: Topic 02 : Introduction to (X)HTML

Document Type Declaration

• The document type declaration specifies the version of HTML that the page uses.

• This example specifies that the page is written using a version of HTML called XHTML 1.0 Strict.

Page 30: Topic 02 : Introduction to (X)HTML

Document Type Declaration

• This is the same document re-written as HTML 5

• Elements, tags and attributes work in exactly the same way.

• Different document type declaration

Page 31: Topic 02 : Introduction to (X)HTML

Document Type Declaration

• There many different versions of (X)HTML including:• HTML 4.01

• XHTML 1.0 Strict

• HTML 5 (not standard yet)

• XHTML is eXtensible HyperText Markup Language• It is HTML re-written to conform to the rules of XML.

• It has stricter syntax than HTML.

Page 32: Topic 02 : Introduction to (X)HTML

Which Version of (X)HTML to Use?

• This module is based around using XHTML 1.0 Strict.

• We will also explore features of the new HTML5 specification

Page 33: Topic 02 : Introduction to (X)HTML

The Root Element

• The root element <html> encloses all other elements

• XMLNS attribute• This specifies the XML namespace for the page.

• lang and xml:lang• These attributes specify the language used to write the document.

Page 34: Topic 02 : Introduction to (X)HTML

Valid Documents

• There are many specific rules for HTML

• These rules are specified in a Document Type Definition (DTD)

• The XHTML Strict 1.0 DTD can be viewed at: http://tinyurl.com/5n5xq

• If an HTML document follows all the rules of the DTD, it is described as being valid.

• We can check if our web pages are valid using the W3Cs validation service http://validator.w3.org/

Page 35: Topic 02 : Introduction to (X)HTML

Why Validate?

• Validating web pages checks we are using web standards.

• Accessibility

• Support standards compliant browsers

• Support a range of devices

Page 36: Topic 02 : Introduction to (X)HTML

Any Questions???Topic 2 : Introduction to (X)HTML

Page 37: Topic 02 : Introduction to (X)HTML

References

• XHTML 1.0 Strict Cheat Sheet• Available at: http://www.w3.org/2010/04/xhtml10-strict.html

• http://www.w3schools.com/html/html_entities.asp