SlideShare a Scribd company logo
HTML
What is HTML?
HTML is a language for describing web pages.
• HTML stands for Hyper Text Markup Language
• HTML is a markup language
• A markup language is a set of markup tags
• The tags describe document content
• HTML documents contain HTML tags and plain
text
• HTML documents are also called web pages
HTML Tags
HTML markup tags are usually called HTML tags
• HTML tags are keywords (tag names) surrounded by
angle brackets like <html>
• HTML tags normally come in pairs like <b> and </b>
• The first tag in a pair is the start tag, the second tag is
the end tag
• The end tag is written like the start tag, with a forward
slash before the tag name
• Start and end tags are also called opening tags and
closing tags
<tagname>content</tagname>
HTML Elements
"HTML tags" and "HTML elements" are often
used to describe the same thing.
• But strictly speaking, an HTML element is
everything between the start tag and the end
tag, including the tags:
• HTML Element:
<p>This is a paragraph.</p>
Web Browsers
• The purpose of a web browser (such as
Google Chrome, Internet Explorer, Firefox,
Safari) is to read HTML documents and display
them as web pages.
• The browser does not display the HTML tags,
but uses the tags to determine how the
content of the HTML page is to be
presented/displayed to the user
HTML Page Structure
Below is a visualization of an HTML page structure:
<html>
<body>
<h1>This a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
Writing HTML
Using Notepad or TextEdit
HTML can be edited by using a professional HTML editor
like:
– Adobe Dreamweaver
– Microsoft Expression Web
– CoffeeCup HTML Editor
• However, for learning HTML we recommend a text
editor like Notepad (PC) or TextEdit (Mac). We believe
using a simple text editor is a good way to learn HTML.
• Follow the 4 steps below to create your first web page
with Notepad.
Start NotepadEdit HTMLSave HTMLRun HTML in Browser
HTML Headings
• HTML headings are defined with the <h1> to
<h6> tags.
Example
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
HTML Paragraphs
• HTML paragraphs are defined with the <p>
tag.
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
HTML Links
• HTML links are defined with the <a> tag.
Example
<a href="http://www.w3schools.com">This is a
link</a>
• Note: The link address is specified in the href
attribute.
HTML Images
• HTML images are defined with the <img> tag.
Example
<img src="w3schools.jpg" width="104" height="142">
HTML Element Syntax
• 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
Start tag * Element content End tag *
<p> This is a paragraph </p>
<a href="default.htm"> This is a link </a>
<br>
Nested HTML Elements
• Most HTML elements can be nested (can
contain other HTML elements).
• HTML documents consist of nested HTML
elements.
HTML Lines
• The <hr>tag creates a horizontal line in an HTML
page.
• The hr element can be used to separate content:
Example
<p>This is a paragraph.</p>
<hr>
<p>This is a paragraph.</p>
<hr>
HTML Comments
• Comments can be inserted into the HTML
code to make it more readable and
understandable. Comments are ignored by
the browser and are not displayed.
Example
<!-- This is a comment -->
How to View HTML Source
• Have you ever seen a Web page and
wondered "Hey! How did they do that?"
• To find out, right-click in the page and select
"View Source" (IE) or "View Page Source"
(Firefox), or similar for other browsers. This
will open a window containing the HTML code
of the page.
HTML Tag Reference
• W3Schools' tag reference contains additional
information about these tags and their
attributes.
Tag Description
<html> Defines an HTML document
<body> Defines the document's body
<h1> to <h6> Defines HTML headings
<hr> Defines a horizontal line
<!--> Defines a comment
Don't Forget the End Tag
• Most browsers will display HTML correctly
even if you forget the end tag:
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.
HTML Line Breaks
• Use the <br> tag if you want a line break (a
new line) without starting a new paragraph:
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.
HTML Formatting Tags
• Often <strong> renders as <b>, and <em> renders as
<i>.
However, there is a difference in the meaning of
these tags:
<b> or <i> defines bold or italic text only.
<strong> or <em> means that you want the text to
be rendered in a way that the user understands as
"important". Today, all major browsers render strong
as bold and em as italics. However, if a browser one
day wants to make a text highlighted with the strong
feature, it might be cursive for example and not
bold!
HTML Text Formatting Tags
Tag Description
<b> Defines bold text
<em> Defines emphasized text
<i> Defines a part of text in an alternate voice or mood
<small> Defines smaller text
<strong> Defines important text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
HTML Hyperlinks (Links)
• The HTML <a> tag defines a hyperlink.
• A hyperlink (or link) is a word, group of words,
or image that you can click on to jump to
another document.
• The HTML code for a link is simple. It looks like
this:
<a href="url">Link text</a>
HTML Links - The target Attribute
• The target attribute specifies where to open
the linked document.
• The example below will open the linked
document in a new browser window or a new
tab:
Example
<a href="http://www.w3schools.com/"
target="_blank">Visit W3Schools!</a>
HTML Links - The id Attribute
• The id attribute can be used to create a bookmark inside an
HTML document.
Example
• An anchor with an id inside an HTML document:
<a id="tips">Useful Tips Section</a>
• Create a link to the "Useful Tips Section" inside the same
document:
<a href="#tips">Visit the Useful Tips Section</a>
• Or, create a link to the "Useful Tips Section" from another
page:
<a href="http://www.w3schools.com/html_links.htm#tips">
Visit the Useful Tips Section</a>
The HTML <style> Element
• The <style> tag is used to define style information for
an HTML document.
• Inside the <style> element you specify how HTML
elements should render in a browser:
<head>
<style type="text/css">
body {background-color:yellow}
p {color:blue}
</style>
</head>
Styling HTML with CSS
• CSS was introduced together with HTML 4, to
provide a better way to style HTML elements.
• CSS can be added to HTML in the following ways:
Inline - using the style attribute in HTML elements
Internal - using the <style> element in the <head>
section
External - using an external CSS file
• The preferred way to add CSS to HTML, is to put CSS
syntax in separate CSS files.
Inline Styles
• An inline style can be used if a unique style is
to be applied to one single occurrence of an
element.
• To use inline styles, use the style attribute in
the relevant tag. The style attribute can
contain any CSS property. The example below
shows how to change the text color and the
left margin of a paragraph:
<p style="color:blue;margin-left:20px;">This is a
paragraph.</p>
<!DOCTYPE html>
<html>
<body>
<h1 style="font-family:verdana;">A
heading</h1>
<p style="font-family:arial;color:red;font-
size:20px;">A paragraph.</p>
</body>
</html>
Internal Style Sheet
• An internal style sheet can be used if one
single document has a unique style. Internal
styles are defined in the <head> section of an
HTML page, by using the <style> tag, like this:
<head>
<style type="text/css">
body {background-color:yellow;}
p {color:blue;}
</style>
</head>
External Style Sheet
• An external style sheet is ideal when the style is applied
to many pages. With an external style sheet, you can
change the look of an entire Web site by changing one
file. Each page must link to the style sheet using the
<link> tag. The <link> tag goes inside the <head> section:
<head>
<link rel="stylesheet" type="text/css“ href="mystyle.css">
</head>
HTML Images - The <img> Tag and
the Src Attribute
• In HTML, images are defined with the <img> tag.
• The <img> tag is empty, which means that it contains
attributes only, and has no closing tag.
• To display an image on a page, you need to use the
src attribute. Src stands for "source". The value of
the src attribute is the URL of the image you want to
display.
<img src="url" alt="some_text">
HTML Images
Set Height and Width of an Image
• The height and width attributes are used to
specify the height and width of an image.
• The attribute values are specified in pixels by
default:
<img src="pulpit.jpg" alt="Pulpit rock"
width="304" height="228">
HTML Tables
• Tables are defined with the <table> tag.
• A table is divided into rows (with the <tr> tag),
and each row is divided into data cells (with
the <td> tag). td stands for "table data," and
holds the content of a data cell. A <td> tag can
contain text, links, images, lists, forms, other
tables, etc.
<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>row 2, cell 2</td>
</tr>
</table>
Styling text
<font color=red size=1 face=calibri>Text1</font>
<font color=blue size=4 face=calibri>Text2</font>
<font color=#ff00ff face=“angsana new”>Text3</font>
HTML Unordered Lists
• An unordered list starts with the <ul> tag.
Each list item starts with the <li> tag.
• The list items are marked with bullets
(typically small black circles).
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
HTML Ordered Lists
• An ordered list starts with the <ol> tag. Each
list item starts with the <li> tag.
• The list items are marked with numbers.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
HTML Description Lists
• A description list is a list of terms/names, with a
description of each term/name.
• The <dl> tag is used in conjunction with <dt> (defines
terms/names) and <dd> (describes each term/name):
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
The HTML <div> Element
• The HTML <div> element is a block level element that can be
used as a container for grouping other HTML elements.
• The <div> element has no special meaning. Except that,
because it is a block level element, the browser will display a
line break before and after it.
• When used together with CSS, the <div> element can be used
to set style attributes to large blocks of content.
• Another common use of the <div> element, is for document
layout. It replaces the "old way" of defining layout using
tables. Using <table> elements for layout is not the correct
use of <table>. The purpose of the <table> element is to
display tabular data.
<div id="container" style="width:500px">
<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;">Main Title of Web Page</h1></div>
<div id="menu" style="background-
color:#FFD700;height:200px;width:100px;float:left;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript</div>
<div id="content" style="background-
color:#EEEEEE;height:200px;width:400px;float:left;">
Content goes here</div>
<div id="footer" style="background-color:#FFA500;clear:both;text-
align:center;">
Copyright © W3Schools.com</div>
</div>
HTML Forms
• HTML forms are used to pass data to a server.
• An HTML form can contain input elements like text
fields, checkboxes, radio-buttons, submit buttons
and more. A form can also contain select lists,
textarea, fieldset, legend, and label elements.
• The <form> tag is used to create an HTML form:
<form>
.
input elements
.
</form>
HTML Input
• The most important form element is the
<input> element.
• The <input> element is used to select user
information.
• An <input> element can vary in many ways,
depending on the type attribute. An <input>
element can be of type text field, checkbox,
password, radio button, submit button, and
more.
Text Fields
• <input type="text"> defines a one-line input field
that a user can enter text into:
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
Password Field
• <input type="password"> defines a password
field:
<form>
Password: <input type="password" name="pwd">
</form>
Radio Buttons
• <input type="radio"> defines a radio button.
Radio buttons let a user select ONLY ONE of a
limited number of choices:
<form>
<input type="radio" name="sex"
value="male">Male<br>
<input type="radio" name="sex"
value="female">Female
</form>
Checkboxes
• <input type="checkbox"> defines a checkbox.
Checkboxes let a user select ZERO or MORE
options of a limited number of choices.
<form>
<input type="checkbox" name="vehicle"
value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle"
value="Car">I have a car
</form>
Submit Button
• <input type="submit"> defines a submit button.
• A submit button is used to send form data to a
server. The data is sent to the page specified in the
form's action attribute. The file defined in the action
attribute usually does something with the received
input:
<form name="input" action="html_form_action.asp"
method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
Simple Drop-Down list
<form action="">
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</form>

More Related Content

PPT
php 1
PPT
Xhtml 2010
PPTX
Html and Xhtml
PPT
Origins and evolution of HTML and XHTML
PDF
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
PDF
Web development using html 5
PDF
Introduction to XML, XHTML and CSS
php 1
Xhtml 2010
Html and Xhtml
Origins and evolution of HTML and XHTML
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
Web development using html 5
Introduction to XML, XHTML and CSS

What's hot (20)

PPTX
Hyper text markup Language
DOCX
HTML Web design english & sinhala mix note
PPTX
Images and Lists in HTML
PDF
HTML 5 Step By Step - Ebook
PPTX
Html Workshop
PDF
Web I - 02 - XHTML Introduction
PPTX
HTML Lists & Llinks
PDF
Html text and formatting
PPTX
Session ii(html)
PPTX
Html basic
PPT
HTML By K.Sasidhar
PPTX
PPT
Unit 2 (html)
PDF
An SEO’s Intro to Web Dev PHP
DOCX
Html example
PPTX
Elements of html powerpoint
PDF
Html full
PPTX
How the Web Works Using HTML
PPTX
Web page concept final ppt
PDF
Session4
Hyper text markup Language
HTML Web design english & sinhala mix note
Images and Lists in HTML
HTML 5 Step By Step - Ebook
Html Workshop
Web I - 02 - XHTML Introduction
HTML Lists & Llinks
Html text and formatting
Session ii(html)
Html basic
HTML By K.Sasidhar
Unit 2 (html)
An SEO’s Intro to Web Dev PHP
Html example
Elements of html powerpoint
Html full
How the Web Works Using HTML
Web page concept final ppt
Session4
Ad

Similar to html (20)

DOC
Html introduction
DOCX
Lesson A.1 - Introduction to Web Development.docx
PPTX
html (1) (1).pptx for all students to learn
PPTX
html.pptx class notes to prepare html completly
DOCX
Computer application html
PPTX
Web Development Basics: HOW TO in HTML
PPTX
Learn html Basics
PDF
Hypertext_markup_language
PDF
Basic Html Notes
PDF
htmlnotes Which tells about all the basic
PDF
htmlnotes-180924151434.pdf dafdkzndsvkdvdd
PDF
HTML Presentation
PDF
Html basics 1
PDF
Html basics
PDF
Html basics
PDF
Html basics
PDF
Html basic file
Html introduction
Lesson A.1 - Introduction to Web Development.docx
html (1) (1).pptx for all students to learn
html.pptx class notes to prepare html completly
Computer application html
Web Development Basics: HOW TO in HTML
Learn html Basics
Hypertext_markup_language
Basic Html Notes
htmlnotes Which tells about all the basic
htmlnotes-180924151434.pdf dafdkzndsvkdvdd
HTML Presentation
Html basics 1
Html basics
Html basics
Html basics
Html basic file
Ad

More from tumetr1 (20)

PDF
ตัวอย่างประวัติผู้วิจัย เล่มโปรเจ็ค
PDF
ตัวอย่างภาคผนวก เล่มโปรเจ็ค
PDF
ตัวอย่างบรรณานุกรม เล่มโปรเจ็ค
PDF
ตัวอย่างบทที่1 บทนำ เล่มโปรเจ็ค
PDF
ตัวอย่างสารบัญ เล่มโปรเจ็ค
PDF
ตัวอย่างกิตติกรรมประกาศ เล่มโปรเจ็ค
PDF
ตัวอย่างบทคัดย่อเล่มโปรเจ็ค
PPT
file transfer and access utilities
PPT
retrieving the mail
PPT
connectivity utility
PPT
network hardware
PPT
ระบบเครือข่ายไร้สาย (wireless lan)
PPT
routing
PPT
the transport layer
PPT
ระดับชั้นเน็ตเวิร์ก
PPT
ระดับชั้นดาต้าลิงค์
PPT
สถาปัตยกรรมเครือข่ายคอมพิวเตอร์และบริการ
PPT
การส่งข้อมูลผ่านสายส่งและเทคนิคการส่งข้อมูลผ่านเครือข่าย
PPT
ความรู้พื้นฐานของระบบการสื่อสารข้อมูล
PPT
พัฒนาเศรษฐกิจ
ตัวอย่างประวัติผู้วิจัย เล่มโปรเจ็ค
ตัวอย่างภาคผนวก เล่มโปรเจ็ค
ตัวอย่างบรรณานุกรม เล่มโปรเจ็ค
ตัวอย่างบทที่1 บทนำ เล่มโปรเจ็ค
ตัวอย่างสารบัญ เล่มโปรเจ็ค
ตัวอย่างกิตติกรรมประกาศ เล่มโปรเจ็ค
ตัวอย่างบทคัดย่อเล่มโปรเจ็ค
file transfer and access utilities
retrieving the mail
connectivity utility
network hardware
ระบบเครือข่ายไร้สาย (wireless lan)
routing
the transport layer
ระดับชั้นเน็ตเวิร์ก
ระดับชั้นดาต้าลิงค์
สถาปัตยกรรมเครือข่ายคอมพิวเตอร์และบริการ
การส่งข้อมูลผ่านสายส่งและเทคนิคการส่งข้อมูลผ่านเครือข่าย
ความรู้พื้นฐานของระบบการสื่อสารข้อมูล
พัฒนาเศรษฐกิจ

Recently uploaded (20)

PDF
01-Introduction-to-Information-Management.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Insiders guide to clinical Medicine.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Pre independence Education in Inndia.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
master seminar digital applications in india
01-Introduction-to-Information-Management.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
RMMM.pdf make it easy to upload and study
Insiders guide to clinical Medicine.pdf
Complications of Minimal Access Surgery at WLH
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial diseases, their pathogenesis and prophylaxis
Pre independence Education in Inndia.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
Week 4 Term 3 Study Techniques revisited.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
master seminar digital applications in india

html

  • 2. What is HTML? HTML is a language for describing web pages. • HTML stands for Hyper Text Markup Language • HTML is a markup language • A markup language is a set of markup tags • The tags describe document content • HTML documents contain HTML tags and plain text • HTML documents are also called web pages
  • 3. HTML Tags HTML markup tags are usually called HTML tags • HTML tags are keywords (tag names) surrounded by angle brackets like <html> • HTML tags normally come in pairs like <b> and </b> • The first tag in a pair is the start tag, the second tag is the end tag • The end tag is written like the start tag, with a forward slash before the tag name • Start and end tags are also called opening tags and closing tags <tagname>content</tagname>
  • 4. HTML Elements "HTML tags" and "HTML elements" are often used to describe the same thing. • But strictly speaking, an HTML element is everything between the start tag and the end tag, including the tags: • HTML Element: <p>This is a paragraph.</p>
  • 5. Web Browsers • The purpose of a web browser (such as Google Chrome, Internet Explorer, Firefox, Safari) is to read HTML documents and display them as web pages. • The browser does not display the HTML tags, but uses the tags to determine how the content of the HTML page is to be presented/displayed to the user
  • 6. HTML Page Structure Below is a visualization of an HTML page structure: <html> <body> <h1>This a heading</h1> <p>This is a paragraph.</p> <p>This is another paragraph.</p> </body> </html>
  • 7. Writing HTML Using Notepad or TextEdit HTML can be edited by using a professional HTML editor like: – Adobe Dreamweaver – Microsoft Expression Web – CoffeeCup HTML Editor • However, for learning HTML we recommend a text editor like Notepad (PC) or TextEdit (Mac). We believe using a simple text editor is a good way to learn HTML. • Follow the 4 steps below to create your first web page with Notepad. Start NotepadEdit HTMLSave HTMLRun HTML in Browser
  • 8. HTML Headings • HTML headings are defined with the <h1> to <h6> tags. Example <h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3>
  • 9. HTML Paragraphs • HTML paragraphs are defined with the <p> tag. Example <p>This is a paragraph.</p> <p>This is another paragraph.</p>
  • 10. HTML Links • HTML links are defined with the <a> tag. Example <a href="http://www.w3schools.com">This is a link</a> • Note: The link address is specified in the href attribute.
  • 11. HTML Images • HTML images are defined with the <img> tag. Example <img src="w3schools.jpg" width="104" height="142">
  • 12. HTML Element Syntax • 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 Start tag * Element content End tag * <p> This is a paragraph </p> <a href="default.htm"> This is a link </a> <br>
  • 13. Nested HTML Elements • Most HTML elements can be nested (can contain other HTML elements). • HTML documents consist of nested HTML elements.
  • 14. HTML Lines • The <hr>tag creates a horizontal line in an HTML page. • The hr element can be used to separate content: Example <p>This is a paragraph.</p> <hr> <p>This is a paragraph.</p> <hr>
  • 15. HTML Comments • Comments can be inserted into the HTML code to make it more readable and understandable. Comments are ignored by the browser and are not displayed. Example <!-- This is a comment -->
  • 16. How to View HTML Source • Have you ever seen a Web page and wondered "Hey! How did they do that?" • To find out, right-click in the page and select "View Source" (IE) or "View Page Source" (Firefox), or similar for other browsers. This will open a window containing the HTML code of the page.
  • 17. HTML Tag Reference • W3Schools' tag reference contains additional information about these tags and their attributes. Tag Description <html> Defines an HTML document <body> Defines the document's body <h1> to <h6> Defines HTML headings <hr> Defines a horizontal line <!--> Defines a comment
  • 18. Don't Forget the End Tag • Most browsers will display HTML correctly even if you forget the end tag: 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.
  • 19. HTML Line Breaks • Use the <br> tag if you want a line break (a new line) without starting a new paragraph: 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.
  • 20. HTML Formatting Tags • Often <strong> renders as <b>, and <em> renders as <i>. However, there is a difference in the meaning of these tags: <b> or <i> defines bold or italic text only. <strong> or <em> means that you want the text to be rendered in a way that the user understands as "important". Today, all major browsers render strong as bold and em as italics. However, if a browser one day wants to make a text highlighted with the strong feature, it might be cursive for example and not bold!
  • 21. HTML Text Formatting Tags Tag Description <b> Defines bold text <em> Defines emphasized text <i> Defines a part of text in an alternate voice or mood <small> Defines smaller text <strong> Defines important text <sub> Defines subscripted text <sup> Defines superscripted text <ins> Defines inserted text <del> Defines deleted text
  • 22. HTML Hyperlinks (Links) • The HTML <a> tag defines a hyperlink. • A hyperlink (or link) is a word, group of words, or image that you can click on to jump to another document. • The HTML code for a link is simple. It looks like this: <a href="url">Link text</a>
  • 23. HTML Links - The target Attribute • The target attribute specifies where to open the linked document. • The example below will open the linked document in a new browser window or a new tab: Example <a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>
  • 24. HTML Links - The id Attribute • The id attribute can be used to create a bookmark inside an HTML document. Example • An anchor with an id inside an HTML document: <a id="tips">Useful Tips Section</a> • Create a link to the "Useful Tips Section" inside the same document: <a href="#tips">Visit the Useful Tips Section</a> • Or, create a link to the "Useful Tips Section" from another page: <a href="http://www.w3schools.com/html_links.htm#tips"> Visit the Useful Tips Section</a>
  • 25. The HTML <style> Element • The <style> tag is used to define style information for an HTML document. • Inside the <style> element you specify how HTML elements should render in a browser: <head> <style type="text/css"> body {background-color:yellow} p {color:blue} </style> </head>
  • 26. Styling HTML with CSS • CSS was introduced together with HTML 4, to provide a better way to style HTML elements. • CSS can be added to HTML in the following ways: Inline - using the style attribute in HTML elements Internal - using the <style> element in the <head> section External - using an external CSS file • The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files.
  • 27. Inline Styles • An inline style can be used if a unique style is to be applied to one single occurrence of an element. • To use inline styles, use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example below shows how to change the text color and the left margin of a paragraph: <p style="color:blue;margin-left:20px;">This is a paragraph.</p>
  • 28. <!DOCTYPE html> <html> <body> <h1 style="font-family:verdana;">A heading</h1> <p style="font-family:arial;color:red;font- size:20px;">A paragraph.</p> </body> </html>
  • 29. Internal Style Sheet • An internal style sheet can be used if one single document has a unique style. Internal styles are defined in the <head> section of an HTML page, by using the <style> tag, like this: <head> <style type="text/css"> body {background-color:yellow;} p {color:blue;} </style> </head>
  • 30. External Style Sheet • An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the <head> section: <head> <link rel="stylesheet" type="text/css“ href="mystyle.css"> </head>
  • 31. HTML Images - The <img> Tag and the Src Attribute • In HTML, images are defined with the <img> tag. • The <img> tag is empty, which means that it contains attributes only, and has no closing tag. • To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display. <img src="url" alt="some_text">
  • 32. HTML Images Set Height and Width of an Image • The height and width attributes are used to specify the height and width of an image. • The attribute values are specified in pixels by default: <img src="pulpit.jpg" alt="Pulpit rock" width="304" height="228">
  • 33. HTML Tables • Tables are defined with the <table> tag. • A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). td stands for "table data," and holds the content of a data cell. A <td> tag can contain text, links, images, lists, forms, other tables, etc.
  • 34. <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>row 2, cell 2</td> </tr> </table>
  • 35. Styling text <font color=red size=1 face=calibri>Text1</font> <font color=blue size=4 face=calibri>Text2</font> <font color=#ff00ff face=“angsana new”>Text3</font>
  • 36. HTML Unordered Lists • An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. • The list items are marked with bullets (typically small black circles). <ul> <li>Coffee</li> <li>Milk</li> </ul>
  • 37. HTML Ordered Lists • An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. • The list items are marked with numbers. <ol> <li>Coffee</li> <li>Milk</li> </ol>
  • 38. HTML Description Lists • A description list is a list of terms/names, with a description of each term/name. • The <dl> tag is used in conjunction with <dt> (defines terms/names) and <dd> (describes each term/name): <dl> <dt>Coffee</dt> <dd>- black hot drink</dd> <dt>Milk</dt> <dd>- white cold drink</dd> </dl>
  • 39. The HTML <div> Element • The HTML <div> element is a block level element that can be used as a container for grouping other HTML elements. • The <div> element has no special meaning. Except that, because it is a block level element, the browser will display a line break before and after it. • When used together with CSS, the <div> element can be used to set style attributes to large blocks of content. • Another common use of the <div> element, is for document layout. It replaces the "old way" of defining layout using tables. Using <table> elements for layout is not the correct use of <table>. The purpose of the <table> element is to display tabular data.
  • 40. <div id="container" style="width:500px"> <div id="header" style="background-color:#FFA500;"> <h1 style="margin-bottom:0;">Main Title of Web Page</h1></div> <div id="menu" style="background- color:#FFD700;height:200px;width:100px;float:left;"> <b>Menu</b><br> HTML<br> CSS<br> JavaScript</div> <div id="content" style="background- color:#EEEEEE;height:200px;width:400px;float:left;"> Content goes here</div> <div id="footer" style="background-color:#FFA500;clear:both;text- align:center;"> Copyright © W3Schools.com</div> </div>
  • 41. HTML Forms • HTML forms are used to pass data to a server. • An HTML form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can also contain select lists, textarea, fieldset, legend, and label elements. • The <form> tag is used to create an HTML form: <form> . input elements . </form>
  • 42. HTML Input • The most important form element is the <input> element. • The <input> element is used to select user information. • An <input> element can vary in many ways, depending on the type attribute. An <input> element can be of type text field, checkbox, password, radio button, submit button, and more.
  • 43. Text Fields • <input type="text"> defines a one-line input field that a user can enter text into: <form> First name: <input type="text" name="firstname"><br> Last name: <input type="text" name="lastname"> </form>
  • 44. Password Field • <input type="password"> defines a password field: <form> Password: <input type="password" name="pwd"> </form>
  • 45. Radio Buttons • <input type="radio"> defines a radio button. Radio buttons let a user select ONLY ONE of a limited number of choices: <form> <input type="radio" name="sex" value="male">Male<br> <input type="radio" name="sex" value="female">Female </form>
  • 46. Checkboxes • <input type="checkbox"> defines a checkbox. Checkboxes let a user select ZERO or MORE options of a limited number of choices. <form> <input type="checkbox" name="vehicle" value="Bike">I have a bike<br> <input type="checkbox" name="vehicle" value="Car">I have a car </form>
  • 47. Submit Button • <input type="submit"> defines a submit button. • A submit button is used to send form data to a server. The data is sent to the page specified in the form's action attribute. The file defined in the action attribute usually does something with the received input: <form name="input" action="html_form_action.asp" method="get"> Username: <input type="text" name="user"> <input type="submit" value="Submit"> </form>
  • 48. Simple Drop-Down list <form action=""> <select name="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat">Fiat</option> <option value="audi">Audi</option> </select> </form>

Editor's Notes

  • #44: ในส่วนนี้จะต้องจำ แพตเทิน