Upload
nest82
View
215
Download
0
Embed Size (px)
Citation preview
8/8/2019 Htlml Tags
1/63
HTML, DHTML, CSS, Java Script
Tag Description DTD
Basic
Defines the document type STF Defines an HTML document STF
Defines the document's body STF
to Defines HTML headings STF
Defines a paragraph STF
Inserts a single line break STF
Defines a horizontal line STF
Defines a comment STF
Formatting
Defines an acronym STF
Defines contact information for the author/owner of a document STF Defines bold text STF
Defines the text direction STF
Defines big text STF
Defines a long quotation STF
Deprecated. Defines centered text TF
Defines a citation STF
Defines computer code text STF
Defines deleted text STF
Defines a definition term STF
Defines emphasized text STF
Deprecated. Defines font, color, and size for text TF
Defines italic text STF
Defines inserted text STF
Defines keyboard text STF
Defines preformatted text STF
Defines sample computer code STF
Defines small text STF
Deprecated. Defines strikethrough text TF
Defines strong text STF
Defines subscripted text STF
Defines superscripted text STF
Defines teletype text STF
Deprecated. Defines underlined text TF
Defines a variable part of a text STF
Deprecated. Defines preformatted text
1
http://www.w3schools.com/tags/tag_doctype.asphttp://www.w3schools.com/tags/tag_doctype.asphttp://www.w3schools.com/tags/tag_html.asphttp://www.w3schools.com/tags/tag_body.asphttp://www.w3schools.com/tags/tag_hn.asphttp://www.w3schools.com/tags/tag_p.asphttp://www.w3schools.com/tags/tag_br.asphttp://www.w3schools.com/tags/tag_hr.asphttp://www.w3schools.com/tags/tag_comment.asphttp://www.w3schools.com/tags/tag_acronym.asphttp://www.w3schools.com/tags/tag_address.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_bdo.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_blockquote.asphttp://www.w3schools.com/tags/tag_center.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_del.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_font.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_ins.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_pre.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_strike.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_u.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_doctype.asphttp://www.w3schools.com/tags/tag_html.asphttp://www.w3schools.com/tags/tag_body.asphttp://www.w3schools.com/tags/tag_hn.asphttp://www.w3schools.com/tags/tag_p.asphttp://www.w3schools.com/tags/tag_br.asphttp://www.w3schools.com/tags/tag_hr.asphttp://www.w3schools.com/tags/tag_comment.asphttp://www.w3schools.com/tags/tag_acronym.asphttp://www.w3schools.com/tags/tag_address.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_bdo.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_blockquote.asphttp://www.w3schools.com/tags/tag_center.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_del.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_font.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_ins.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_pre.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_strike.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_u.asphttp://www.w3schools.com/tags/tag_phrase_elements.asp8/8/2019 Htlml Tags
2/63
Forms
Defines an HTML form for user input STF
Defines an input control STF
Defines a multi-line text input control STF
Defines a push button STF
Defines a select list (drop-down list) STF
Defines a group of related options in a select list STF
Defines an option in a select list STF
Defines a label for an input element STF
Defines a border around elements in a form STF
Defines a caption for a fieldset element STF
Deprecated. Defines a searchable index related to a document TF
Frames
Defines a window (a frame) in a frameset F
Defines a set of frames F Defines an alternate content for users that do not support frames TF
Defines an inline frame TF
Images
Defines an image STF
Defines an image-map STF
Defines an area inside an image-map STF
Links
Defines an anchor STF
Defines the relationship between a document and an external resource STF
Lists Defines an unordered list STF
Defines an ordered list STF
Defines a list item STF
Deprecated. Defines a directory list TF
Defines a definition list STF
Defines a term (an item) in a definition list STF
Defines a description of a term in a definition list STF
Deprecated. Defines a menu list TF
Tables
Defines a table STF
Defines a table caption STF
Defines a header cell in a table STF
Defines a row in a table STF
Defines a cell in a table STF
Groups the header content in a table STF
Groups the body content in a table STF
2
http://www.w3schools.com/tags/tag_form.asphttp://www.w3schools.com/tags/tag_input.asphttp://www.w3schools.com/tags/tag_textarea.asphttp://www.w3schools.com/tags/tag_button.asphttp://www.w3schools.com/tags/tag_select.asphttp://www.w3schools.com/tags/tag_optgroup.asphttp://www.w3schools.com/tags/tag_option.asphttp://www.w3schools.com/tags/tag_label.asphttp://www.w3schools.com/tags/tag_fieldset.asphttp://www.w3schools.com/tags/tag_legend.asphttp://www.w3schools.com/tags/tag_frame.asphttp://www.w3schools.com/tags/tag_frameset.asphttp://www.w3schools.com/tags/tag_noframes.asphttp://www.w3schools.com/tags/tag_iframe.asphttp://www.w3schools.com/tags/tag_img.asphttp://www.w3schools.com/tags/tag_map.asphttp://www.w3schools.com/tags/tag_area.asphttp://www.w3schools.com/tags/tag_a.asphttp://www.w3schools.com/tags/tag_link.asphttp://www.w3schools.com/tags/tag_ul.asphttp://www.w3schools.com/tags/tag_ol.asphttp://www.w3schools.com/tags/tag_li.asphttp://www.w3schools.com/tags/tag_dir.asphttp://www.w3schools.com/tags/tag_dl.asphttp://www.w3schools.com/tags/tag_dt.asphttp://www.w3schools.com/tags/tag_dd.asphttp://www.w3schools.com/tags/tag_menu.asphttp://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_caption.asphttp://www.w3schools.com/tags/tag_th.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_td.asphttp://www.w3schools.com/tags/tag_thead.asphttp://www.w3schools.com/tags/tag_tbody.asphttp://www.w3schools.com/tags/tag_form.asphttp://www.w3schools.com/tags/tag_input.asphttp://www.w3schools.com/tags/tag_textarea.asphttp://www.w3schools.com/tags/tag_button.asphttp://www.w3schools.com/tags/tag_select.asphttp://www.w3schools.com/tags/tag_optgroup.asphttp://www.w3schools.com/tags/tag_option.asphttp://www.w3schools.com/tags/tag_label.asphttp://www.w3schools.com/tags/tag_fieldset.asphttp://www.w3schools.com/tags/tag_legend.asphttp://www.w3schools.com/tags/tag_frame.asphttp://www.w3schools.com/tags/tag_frameset.asphttp://www.w3schools.com/tags/tag_noframes.asphttp://www.w3schools.com/tags/tag_iframe.asphttp://www.w3schools.com/tags/tag_img.asphttp://www.w3schools.com/tags/tag_map.asphttp://www.w3schools.com/tags/tag_area.asphttp://www.w3schools.com/tags/tag_a.asphttp://www.w3schools.com/tags/tag_link.asphttp://www.w3schools.com/tags/tag_ul.asphttp://www.w3schools.com/tags/tag_ol.asphttp://www.w3schools.com/tags/tag_li.asphttp://www.w3schools.com/tags/tag_dir.asphttp://www.w3schools.com/tags/tag_dl.asphttp://www.w3schools.com/tags/tag_dt.asphttp://www.w3schools.com/tags/tag_dd.asphttp://www.w3schools.com/tags/tag_menu.asphttp://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_caption.asphttp://www.w3schools.com/tags/tag_th.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_td.asphttp://www.w3schools.com/tags/tag_thead.asphttp://www.w3schools.com/tags/tag_tbody.asp8/8/2019 Htlml Tags
3/63
Groups the footer content in a table STF
Defines attribute values for one or more columns in a table STF
Styles
Defines style information for a document STF
Defines a section in a document STF
Defines a section in a document STF
Meta Info
Defines information about the document STF
Defines the document title STF
Defines metadata about an HTML document STF
Defines a default address or a default target for all links on a page STF
Deprecated. Defines a default font, color, or size for the text in a page TF
Programming
Defines a client-side script STF
Defines an alternate content for users that do not support client-side scripts STF Deprecated. Defines an embedded applet TF
Defines an embedded object STF
Defines a parameter for an object STF
Keyboard Events
Valid in all elements except base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style,and title.
Attribute Value Description
onkeydown script Script to be run when a key is pressed
onkeypress script Script to be run when a key is pressed and released
onkeyup script Script to be run when a key is released
====================================
Defines an HTML document
Defines the document's body
HTML Links
HTML links are defined with the tag.ExampleThis is a link
3
http://www.w3schools.com/tags/tag_tfoot.asphttp://www.w3schools.com/tags/tag_col.asphttp://www.w3schools.com/tags/tag_style.asphttp://www.w3schools.com/tags/tag_div.asphttp://www.w3schools.com/tags/tag_span.asphttp://www.w3schools.com/tags/tag_head.asphttp://www.w3schools.com/tags/tag_title.asphttp://www.w3schools.com/tags/tag_meta.asphttp://www.w3schools.com/tags/tag_base.asphttp://www.w3schools.com/tags/tag_basefont.asphttp://www.w3schools.com/tags/tag_script.asphttp://www.w3schools.com/tags/tag_noscript.asphttp://www.w3schools.com/tags/tag_applet.asphttp://www.w3schools.com/tags/tag_object.asphttp://www.w3schools.com/tags/tag_param.asphttp://www.w3schools.com/tags/tag_tfoot.asphttp://www.w3schools.com/tags/tag_col.asphttp://www.w3schools.com/tags/tag_style.asphttp://www.w3schools.com/tags/tag_div.asphttp://www.w3schools.com/tags/tag_span.asphttp://www.w3schools.com/tags/tag_head.asphttp://www.w3schools.com/tags/tag_title.asphttp://www.w3schools.com/tags/tag_meta.asphttp://www.w3schools.com/tags/tag_base.asphttp://www.w3schools.com/tags/tag_basefont.asphttp://www.w3schools.com/tags/tag_script.asphttp://www.w3schools.com/tags/tag_noscript.asphttp://www.w3schools.com/tags/tag_applet.asphttp://www.w3schools.com/tags/tag_object.asphttp://www.w3schools.com/tags/tag_param.asp8/8/2019 Htlml Tags
4/63
HTML Images
HTML Image TagsTag Description Defines an image Defines an image-map Defines a clickable area inside an image-map
HTML images are defined with the tag.Example
Nested HTML Elements
This is my first paragraph.
The element:
This is my first paragraph.
------------------------------------------------
HTML Attributes
Attributes provide additional information about HTML elements.HTML Attributes
* HTML elements can have attributes* Attributes provide additional information about an element* Attributes are always specified in the start tag* Attributes come in name/value pairs like: name="value"
Attribute Example
Attribute values should always be enclosed in quotes.
HTML links are defined with the tag. The link address is specified in the href attribute:Example
This is a link
--------------------------------------------------------
Headings
Use HTML headings for headings only. Don't use headings to make text BIG or bold.
This is a headingThis is a heading
4
8/8/2019 Htlml Tags
5/63
This is a headingThis is a headingThis is a headingThis is a heading
--------------------------------------------------------
HTML Comments
Comments can be inserted into the HTML code to make it more readable and understandable. Commentsare ignored by the browser and are not displayed.
Comments are written like this:
Example
---------------------------------------------------------
HTML Paragraphs
HTML documents are divided into paragraphs.HTML Paragraphs
Paragraphs are defined with the
tag.Example
This is a paragraph
This is another paragraph
Note: Browsers automatically add an empty line before and after a paragraph.-----------------------------------------------------------------------------
HTML Line Breaks
Inserts a single line break
Use the
tag if you want a line break (a new line) without starting a new
paragraph:Example
This is
a para
graph with line breaks
The
element is an empty HTML element. It has no end tag.
or
--------------------------------------------------------------------------------------------
HTML Text Formatting
This text is bold
This text is big
5
8/8/2019 Htlml Tags
6/63
This text is italic
This is computer output
This is subscript andsuperscript
Often renders as , and renders as .
However, there is a difference in the meaning of these tags:
or defines bold or italic text only.
or means that you want the text to be rendered in a way thatthe user understands as "important".
Today, all major browsers render strong as bold and em as italics. However, if a browser one day wants tomake a text highlighted with the strong feature, it might be cursive for example and not bold!
--------------------------------------------------------------------------
HTML Text Formatting Tags
Tag Description Defines bold text Defines big text Defines emphasized text Defines italic text Defines small text Defines strong text Defines subscripted text Defines superscripted text Defines inserted text Defines deleted text
HTML "Computer Output" Tags
Tag Description
Defines computer code text Defines keyboard text Defines sample computer code Defines teletype text Defines a variable Defines preformatted text
-------------------------------------------------------------------------------------
HTML Styles
Look! Styles and colors
This text is in Verdana and red
This text is in Times and blue
This text is 30 pixels high
6
8/8/2019 Htlml Tags
7/63
Tags Description Defines centered content and Defines HTML fonts and Defines strikethrough text Defines underlined text Attributes Description align Defines thealignment of text bgcolor Defines the background color color Defines the text color
HTML Style Example - Background Color
The background-color property defines the background color for an element:
This is a heading
This is a paragraph.
HTML Style Example - Font, Color and Size
The font-family, color, and font-size properties defines the font, color, and size of the text in an element:
A heading
A paragraph.
HTML Style Example - Text Alignment
The text-align property specifies the horizontal alignment of text in an element:
This is a heading
The heading above is aligned to the center of this page.
HTML Images
7
8/8/2019 Htlml Tags
8/63
8/8/2019 Htlml Tags
9/63
A paragraph with an image. The align attribute of the image is set to "right". The image will float to theright of this text.
Make a Hyperlink of an Image
Create a link of an image:
No border around the image, but still a link:
Create an Image Map
Click on the sun or on one of the planets to watch it closer:
HTML Tables
Apples 44%
9
8/8/2019 Htlml Tags
10/63
Bananas 23%
Oranges 13%
Other 10%
HTML Table Tags
Tag Description
Defines a table
Defines a table header
Defines a table row
Defines a table cell
Defines a table caption
Defines a group of columns in a table, for formatting
Defines attribute values for one or more columns in a table
Groups the header content in a table Groups the body content in a table
Groups the footer content in a table
Table Example
row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2
HTML Tables and the Border Attribute
If you do not specify a border attribute, the table will be displayed without borders. Sometimes this can beuseful, but most of the time, we want the borders to show.
To display a table with borders, specify the border attribute:
10
http://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_th.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_td.asphttp://www.w3schools.com/tags/tag_caption.asphttp://www.w3schools.com/tags/tag_colgroup.asphttp://www.w3schools.com/tags/tag_col.asphttp://www.w3schools.com/tags/tag_thead.asphttp://www.w3schools.com/tags/tag_tbody.asphttp://www.w3schools.com/tags/tag_tfoot.asphttp://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_th.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_td.asphttp://www.w3schools.com/tags/tag_caption.asphttp://www.w3schools.com/tags/tag_colgroup.asphttp://www.w3schools.com/tags/tag_col.asphttp://www.w3schools.com/tags/tag_thead.asphttp://www.w3schools.com/tags/tag_tbody.asphttp://www.w3schools.com/tags/tag_tfoot.asp8/8/2019 Htlml Tags
11/63
Row 1, cell 1Row 1, cell 2
HTML Table Headers
Header information in a table are defined with the tag.
The text in a th element will be bold and centered.
Header 1Header 2
row 1, cell 1row 1, cell 2row 2, cell 1row 2, cell 2
How the HTML code above looks in a browser:
Header 1 Header 2
row 1, cell 1 row 1, cell 2row 2, cell 1 row 2, cell 2
Table Without Border:
html>
This table has no borders:
100200300
400500600
11
8/8/2019 Htlml Tags
12/63
And this table has no borders:
100200300
400500600
Table Header:
Table headers:
NameTelephoneTelephone
Bill Gates555 77 854555 77 855
Vertical headers:
First Name:Bill Gates
Telephone:555 77 854
Telephone:555 77 855
12
8/8/2019 Htlml Tags
13/63
Table headers:Name Telephone Telephone
Bill Gates 555 77 854 555 77 855
Vertical headers:
First Name: Bill Gates
Telephone: 555 77 854
Telephone: 555 77 855
Table with a Caption:
Monthly savings
MonthSavings
January$100
February$50
Cell Spanning:
Cell that spans two columns:
13
8/8/2019 Htlml Tags
14/63
NameTelephone
Bill Gates555 77 854555 77 855
Cell that spans two rows:
First Name:Bill Gates
Telephone:
555 77 854
555 77 855
Cell that spans two columns:
Name Telephone
Bill Gates 555 77 854 555 77 855
Cell that spans two rows:
First Name: Bill Gates
Telephone:555 77 854
555 77 855
----------------------------------------------------------------------------------------------------
Tag inside Table:
This is a paragraph
This is another paragraph
14
8/8/2019 Htlml Tags
15/63
8/8/2019 Htlml Tags
16/63
FirstRow
SecondRow
With cellpadding:
FirstRow
Second
Row
Without cellpadding:
First Row
Second Row
With cellpadding:
First Row
Second Row
Cell Spacing:
Without cellspacing:
FirstRow
16
8/8/2019 Htlml Tags
17/63
SecondRow
With cellspacing:
FirstRow
SecondRow
Without cellspacing:
First Row
Second Row
With cellspacing:
First Row
Second Row
The Frame Attribute:
Note:If you see no frames/borders around the tables below, your browser does not supportthe "frame" attribute.
With frame="border":
FirstRow
SecondRow
17
8/8/2019 Htlml Tags
18/63
With frame="box":
FirstRow
SecondRow
With frame="void":
FirstRow
SecondRow
With frame="above":
FirstRow
SecondRow
With frame="below":
FirstRow
SecondRow
With frame="hsides":
FirstRow
18
8/8/2019 Htlml Tags
19/63
SecondRow
With frame="vsides":
FirstRow
SecondRow
With frame="lhs":
FirstRow
SecondRow
With frame="rhs":
FirstRow
SecondRow
Note: If you see no frames/borders around the tables below, your browser does not support the "frame"attribute.
With frame="border":
First Row
Second Row
19
8/8/2019 Htlml Tags
20/63
With frame="box":
First Row
Second Row
With frame="void":
First RowSecond Row
With frame="above":
First Row
Second Row
With frame="below":
First Row
Second Row
With frame="hsides":
First Row
Second Row
With frame="vsides":
First Row
Second Row
With frame="lhs":
First Row
Second Row
With frame="rhs":
First Row
Second Row
HTML Tag
Example
Two colgroup elements that specify different alignment and style for the three columns in the table (noticethat the first colgroup element spans two columns):
ISBNTitlePrice
20
8/8/2019 Htlml Tags
21/63
3476896My first HTML$53
Definition and Usage
The tag is used to group columns in a table for formatting.
The tag is useful for applying styles to entire columns, instead of repeating the styles for eachcell, for each row.
The tag can only be used inside a table element.
Define Column value in Center or right or left in table:
ISBNTitlePrice
3476896My first HTML$53
HTML Tag
Example
An HTML table with a thead, tfoot, and a tbody element:
MonthSavings
21
8/8/2019 Htlml Tags
22/63
Sum$180
January$100
February$80
HTML Lists
The most common HTML lists are ordered and unordered lists:
HTML Lists
An ordered list:
1. The first list item2. The second list item
3. The third list item
An unordered list:
List item
List item
List item
Tag Description
Defines an ordered list
Defines an unordered list
Defines a list item
Defines a definition list
Defines an item in a definition list
Defines a description of an item in a definition list
HTML Unordered Lists
An unordered list starts with the tag. Each list item starts with the tag.
The list items are marked with bullets (typically small black circles).
22
http://www.w3schools.com/tags/tag_ol.asphttp://www.w3schools.com/tags/tag_ul.asphttp://www.w3schools.com/tags/tag_li.asphttp://www.w3schools.com/tags/tag_dl.asphttp://www.w3schools.com/tags/tag_dt.asphttp://www.w3schools.com/tags/tag_dd.asphttp://www.w3schools.com/tags/tag_ol.asphttp://www.w3schools.com/tags/tag_ul.asphttp://www.w3schools.com/tags/tag_li.asphttp://www.w3schools.com/tags/tag_dl.asphttp://www.w3schools.com/tags/tag_dt.asphttp://www.w3schools.com/tags/tag_dd.asp8/8/2019 Htlml Tags
23/63
CoffeeMilk
How the HTML code above looks in a browser:
Coffee
Milk
HTML Ordered Lists
An ordered list starts with the tag. Each list item starts with the tag.
The list items are marked with numbers.
CoffeeMilk
How the HTML code above looks in a browser:
1. Coffee2. Milk
HTML Definition Lists
A definition list is a list of items, with a description of each item.
The tag defines a definition list.
The tag is used in conjunction with (defines the item in the list) and (describes the item inthe list):
Coffee- black hot drinkMilk
- white cold drink
How the HTML code above looks in a browser:
Coffee- black hot drink
Milk- white cold drink
23
8/8/2019 Htlml Tags
24/63
8/8/2019 Htlml Tags
25/63
d. Oranges
Roman numbers list:
I. ApplesII. Bananas
III. LemonsIV. Oranges
Lowercase Roman numbers list:
i. Applesii. Bananas
iii. Lemonsiv. Oranges
Different Types of Un-ordered Lists
Disc bullets list:ApplesBananasLemonsOranges
Circle bullets list:ApplesBananasLemonsOranges
Square bullets list:ApplesBananasLemons
Oranges
25
8/8/2019 Htlml Tags
26/63
Disc bullets list:
Apples
Bananas
Lemons
Oranges
Circle bullets list:
o Apples
o Bananas
o Lemons
o Oranges
Square bullets list:
Apples
Bananas Lemons
Oranges
Nested Lists:
A nested List:
Coffee
Tea
Black tea
Green tea
Milk
26
8/8/2019 Htlml Tags
27/63
A nested List:
Coffee
Teao Black tea
o Green tea
Milk
Definition List:
A Definition List:
Coffee
Black hot drink
Milk
White cold drink
A Definition List:
CoffeeBlack hot drink
MilkWhite cold drink
HTML Forms and Input
27
8/8/2019 Htlml Tags
28/63
HTML Form Tags
Tag Description
Defines an HTML form for user input
Defines an input control
Defines a multi-line text input control
Defines a label for an input element
Defines a border around elements in a form
Defines a caption for a fieldset element
Defines a select list (drop-down list)
Defines a group of related options in a select list
Defines an option in a select list
Defines a push button
HTML Forms
HTML forms are used to pass data to a server.
A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. Aform can also contain select lists, textarea, fieldset, legend, and label elements.
28
http://www.w3schools.com/tags/tag_form.asphttp://www.w3schools.com/tags/tag_input.asphttp://www.w3schools.com/tags/tag_textarea.asphttp://www.w3schools.com/tags/tag_label.asphttp://www.w3schools.com/tags/tag_fieldset.asphttp://www.w3schools.com/tags/tag_legend.asphttp://www.w3schools.com/tags/tag_select.asphttp://www.w3schools.com/tags/tag_optgroup.asphttp://www.w3schools.com/tags/tag_option.asphttp://www.w3schools.com/tags/tag_button.asphttp://www.w3schools.com/tags/tag_form.asphttp://www.w3schools.com/tags/tag_input.asphttp://www.w3schools.com/tags/tag_textarea.asphttp://www.w3schools.com/tags/tag_label.asphttp://www.w3schools.com/tags/tag_fieldset.asphttp://www.w3schools.com/tags/tag_legend.asphttp://www.w3schools.com/tags/tag_select.asphttp://www.w3schools.com/tags/tag_optgroup.asphttp://www.w3schools.com/tags/tag_option.asphttp://www.w3schools.com/tags/tag_button.asp8/8/2019 Htlml Tags
29/63
HTML Forms and Input
HTML Forms are used to select different kinds of user input.
Text Fields
defines a one-line input field that a user can enter text into:
First name:
Last name:
How the HTML code above looks in a browser:
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of a text field is 20 characters.
Password Field
defines a password field:
Password:
How the HTML code above looks in a browser:
Password:
Note: The characters in a password field are masked (shown as asterisks or circles).
Radio Buttons
defines a radio button. Radio buttons let a user select ONLY ONE one of a limited number ofchoices:
Male
Female
29
8/8/2019 Htlml Tags
30/63
Form Button:
---------------------------------------------------------------------------------------------
Border around form:
Personal information:Name:
E-mail:
Date of birth:
Personal information: Name:
E-mail:
Date of birth:
Form with Radio Button:
Male
Female
If you click the "Submit" button, the form-data will be sent to a page called"html_form_action.asp".
30
8/8/2019 Htlml Tags
31/63
Male
Female
Submit
If you click the "Submit" button, the form-data will be sent to a page called "html_form_action.asp".
Send Email from Form:
Send e-mail to [email protected]:
Name:
E-mail:
Comment:
Send e-mail to [email protected]:
Name:
E-mail:
Comment:
Submit
HTML Colors
Colors are displayed combining RED, GREEN, and BLUE light.
31
8/8/2019 Htlml Tags
32/63
Color Values
HTML colors are defined using a hexadecimal notation (HEX) for the combination of Red, Green, andBlue color values (RGB).
The lowest value that can be given to one of the light sources is 0 (in HEX: 00). The highest value is 255(in HEX: FF).
HEX values are specified as 3 pairs of two-digit numbers, starting with a # sign.
Color Values
Color Color HEX Color RGB
#000000 rgb(0,0,0)
#FF0000 rgb(255,0,0)
#00FF00 rgb(0,255,0)
#0000FF rgb(0,0,255)
#FFFF00 rgb(255,255,0)
#00FFFF rgb(0,255,255)
#FF00FF rgb(255,0,255)
#C0C0C0 rgb(192,192,192)
#FFFFFF rgb(255,255,255)
16 Million Different Colors
The combination of Red, Green, and Blue values from 0 to 255, gives more than 16 million different colors(256 x 256 x 256).
If you look at the color table below, you will see the result of varying the red light from 0 to 255, whilekeeping the green and blue light at zero.
To see the full list of color mixes when RED varies from 0 to 255, click on one of the HEX or RGB valuesbelow.
Red Light Color HEX Color RGB
#000000 rgb(0,0,0)
#080000 rgb(8,0,0)
#100000 rgb(16,0,0)
#180000 rgb(24,0,0)
#200000 rgb(32,0,0)
#280000 rgb(40,0,0)
32
http://www.w3schools.com/html/html_colorsmore.asp?color=0http://www.w3schools.com/html/html_colorsmore.asp?color=0http://www.w3schools.com/html/html_colorsmore.asp?color=0http://www.w3schools.com/html/html_colorsmore.asp?color=0http://www.w3schools.com/html/html_colorsmore.asp?color=8http://www.w3schools.com/html/html_colorsmore.asp?color=8http://www.w3schools.com/html/html_colorsmore.asp?color=8http://www.w3schools.com/html/html_colorsmore.asp?color=8http://www.w3schools.com/html/html_colorsmore.asp?color=16http://www.w3schools.com/html/html_colorsmore.asp?color=16http://www.w3schools.com/html/html_colorsmore.asp?color=16http://www.w3schools.com/html/html_colorsmore.asp?color=16http://www.w3schools.com/html/html_colorsmore.asp?color=24http://www.w3schools.com/html/html_colorsmore.asp?color=24http://www.w3schools.com/html/html_colorsmore.asp?color=24http://www.w3schools.com/html/html_colorsmore.asp?color=24http://www.w3schools.com/html/html_colorsmore.asp?color=32http://www.w3schools.com/html/html_colorsmore.asp?color=32http://www.w3schools.com/html/html_colorsmore.asp?color=32http://www.w3schools.com/html/html_colorsmore.asp?color=32http://www.w3schools.com/html/html_colorsmore.asp?color=40http://www.w3schools.com/html/html_colorsmore.asp?color=40http://www.w3schools.com/html/html_colorsmore.asp?color=40http://www.w3schools.com/html/html_colorsmore.asp?color=40http://www.w3schools.com/html/html_colorsmore.asp?color=0http://www.w3schools.com/html/html_colorsmore.asp?color=0http://www.w3schools.com/html/html_colorsmore.asp?color=8http://www.w3schools.com/html/html_colorsmore.asp?color=8http://www.w3schools.com/html/html_colorsmore.asp?color=16http://www.w3schools.com/html/html_colorsmore.asp?color=16http://www.w3schools.com/html/html_colorsmore.asp?color=24http://www.w3schools.com/html/html_colorsmore.asp?color=24http://www.w3schools.com/html/html_colorsmore.asp?color=32http://www.w3schools.com/html/html_colorsmore.asp?color=32http://www.w3schools.com/html/html_colorsmore.asp?color=40http://www.w3schools.com/html/html_colorsmore.asp?color=408/8/2019 Htlml Tags
33/63
#300000 rgb(48,0,0)
#380000 rgb(56,0,0)
#400000 rgb(64,0,0)
#480000 rgb(72,0,0)
#500000 rgb(80,0,0)
#580000 rgb(88,0,0)
#600000 rgb(96,0,0)
#680000 rgb(104,0,0)
#700000 rgb(112,0,0)
#780000 rgb(120,0,0)
#800000 rgb(128,0,0)
#880000 rgb(136,0,0)
#900000 rgb(144,0,0)
#980000 rgb(152,0,0)
#A00000 rgb(160,0,0)#A80000 rgb(168,0,0)
#B00000 rgb(176,0,0)
#B80000 rgb(184,0,0)
#C00000 rgb(192,0,0)
#C80000 rgb(200,0,0)
#D00000 rgb(208,0,0)
#D80000 rgb(216,0,0)
#E00000 rgb(224,0,0)
#E80000 rgb(232,0,0)
#F00000 rgb(240,0,0)#F80000 rgb(248,0,0)
#FF0000 rgb(255,0,0)
Shades of Gray
Gray colors are created by using an equal amount of power to all of the light sources.
To make it easier for you to select the correct shade, we have created a table of gray shades for you:
Gray Shades Color HEX Color RGB
#000000 rgb(0,0,0)
#080808 rgb(8,8,8)
#101010 rgb(16,16,16)
#181818 rgb(24,24,24)
#202020 rgb(32,32,32)
#282828 rgb(40,40,40)
33
http://www.w3schools.com/html/html_colorsmore.asp?color=48http://www.w3schools.com/html/html_colorsmore.asp?color=48http://www.w3schools.com/html/html_colorsmore.asp?color=48http://www.w3schools.com/html/html_colorsmore.asp?color=48http://www.w3schools.com/html/html_colorsmore.asp?color=56http://www.w3schools.com/html/html_colorsmore.asp?color=56http://www.w3schools.com/html/html_colorsmore.asp?color=56http://www.w3schools.com/html/html_colorsmore.asp?color=56http://www.w3schools.com/html/html_colorsmore.asp?color=64http://www.w3schools.com/html/html_colorsmore.asp?color=64http://www.w3schools.com/html/html_colorsmore.asp?color=64http://www.w3schools.com/html/html_colorsmore.asp?color=64http://www.w3schools.com/html/html_colorsmore.asp?color=72http://www.w3schools.com/html/html_colorsmore.asp?color=72http://www.w3schools.com/html/html_colorsmore.asp?color=72http://www.w3schools.com/html/html_colorsmore.asp?color=72http://www.w3schools.com/html/html_colorsmore.asp?color=80http://www.w3schools.com/html/html_colorsmore.asp?color=80http://www.w3schools.com/html/html_colorsmore.asp?color=80http://www.w3schools.com/html/html_colorsmore.asp?color=80http://www.w3schools.com/html/html_colorsmore.asp?color=88http://www.w3schools.com/html/html_colorsmore.asp?color=88http://www.w3schools.com/html/html_colorsmore.asp?color=88http://www.w3schools.com/html/html_colorsmore.asp?color=88http://www.w3schools.com/html/html_colorsmore.asp?color=96http://www.w3schools.com/html/html_colorsmore.asp?color=96http://www.w3schools.com/html/html_colorsmore.asp?color=96http://www.w3schools.com/html/html_colorsmore.asp?color=96http://www.w3schools.com/html/html_colorsmore.asp?color=104http://www.w3schools.com/html/html_colorsmore.asp?color=104http://www.w3schools.com/html/html_colorsmore.asp?color=104http://www.w3schools.com/html/html_colorsmore.asp?color=104http://www.w3schools.com/html/html_colorsmore.asp?color=112http://www.w3schools.com/html/html_colorsmore.asp?color=112http://www.w3schools.com/html/html_colorsmore.asp?color=112http://www.w3schools.com/html/html_colorsmore.asp?color=112http://www.w3schools.com/html/html_colorsmore.asp?color=120http://www.w3schools.com/html/html_colorsmore.asp?color=120http://www.w3schools.com/html/html_colorsmore.asp?color=120http://www.w3schools.com/html/html_colorsmore.asp?color=120http://www.w3schools.com/html/html_colorsmore.asp?color=128http://www.w3schools.com/html/html_colorsmore.asp?color=128http://www.w3schools.com/html/html_colorsmore.asp?color=128http://www.w3schools.com/html/html_colorsmore.asp?color=128http://www.w3schools.com/html/html_colorsmore.asp?color=136http://www.w3schools.com/html/html_colorsmore.asp?color=136http://www.w3schools.com/html/html_colorsmore.asp?color=136http://www.w3schools.com/html/html_colorsmore.asp?color=136http://www.w3schools.com/html/html_colorsmore.asp?color=144http://www.w3schools.com/html/html_colorsmore.asp?color=144http://www.w3schools.com/html/html_colorsmore.asp?color=144http://www.w3schools.com/html/html_colorsmore.asp?color=144http://www.w3schools.com/html/html_colorsmore.asp?color=152http://www.w3schools.com/html/html_colorsmore.asp?color=152http://www.w3schools.com/html/html_colorsmore.asp?color=152http://www.w3schools.com/html/html_colorsmore.asp?color=152http://www.w3schools.com/html/html_colorsmore.asp?color=160http://www.w3schools.com/html/html_colorsmore.asp?color=160http://www.w3schools.com/html/html_colorsmore.asp?color=160http://www.w3schools.com/html/html_colorsmore.asp?color=160http://www.w3schools.com/html/html_colorsmore.asp?color=168http://www.w3schools.com/html/html_colorsmore.asp?color=168http://www.w3schools.com/html/html_colorsmore.asp?color=168http://www.w3schools.com/html/html_colorsmore.asp?color=168http://www.w3schools.com/html/html_colorsmore.asp?color=176http://www.w3schools.com/html/html_colorsmore.asp?color=176http://www.w3schools.com/html/html_colorsmore.asp?color=176http://www.w3schools.com/html/html_colorsmore.asp?color=184http://www.w3schools.com/html/html_colorsmore.asp?color=184http://www.w3schools.com/html/html_colorsmore.asp?color=184http://www.w3schools.com/html/html_colorsmore.asp?color=192http://www.w3schools.com/html/html_colorsmore.asp?color=192http://www.w3schools.com/html/html_colorsmore.asp?color=192http://www.w3schools.com/html/html_colorsmore.asp?color=200http://www.w3schools.com/html/html_colorsmore.asp?color=200http://www.w3schools.com/html/html_colorsmore.asp?color=200http://www.w3schools.com/html/html_colorsmore.asp?color=208http://www.w3schools.com/html/html_colorsmore.asp?color=208http://www.w3schools.com/html/html_colorsmore.asp?color=208http://www.w3schools.com/html/html_colorsmore.asp?color=208http://www.w3schools.com/html/html_colorsmore.asp?color=216http://www.w3schools.com/html/html_colorsmore.asp?color=216http://www.w3schools.com/html/html_colorsmore.asp?color=216http://www.w3schools.com/html/html_colorsmore.asp?color=216http://www.w3schools.com/html/html_colorsmore.asp?color=224http://www.w3schools.com/html/html_colorsmore.asp?color=224http://www.w3schools.com/html/html_colorsmore.asp?color=224http://www.w3schools.com/html/html_colorsmore.asp?color=224http://www.w3schools.com/html/html_colorsmore.asp?color=232http://www.w3schools.com/html/html_colorsmore.asp?color=232http://www.w3schools.com/html/html_colorsmore.asp?color=232http://www.w3schools.com/html/html_colorsmore.asp?color=232http://www.w3schools.com/html/html_colorsmore.asp?color=240http://www.w3schools.com/html/html_colorsmore.asp?color=240http://www.w3schools.com/html/html_colorsmore.asp?color=240http://www.w3schools.com/html/html_colorsmore.asp?color=248http://www.w3schools.com/html/html_colorsmore.asp?color=248http://www.w3schools.com/html/html_colorsmore.asp?color=248http://www.w3schools.com/html/html_colorsmore.asp?color=255http://www.w3schools.com/html/html_colorsmore.asp?color=255http://www.w3schools.com/html/html_colorsmore.asp?color=255http://www.w3schools.com/html/html_colorsmore.asp?color=255http://www.w3schools.com/html/html_colorsmore.asp?color=48http://www.w3schools.com/html/html_colorsmore.asp?color=48http://www.w3schools.com/html/html_colorsmore.asp?color=56http://www.w3schools.com/html/html_colorsmore.asp?color=56http://www.w3schools.com/html/html_colorsmore.asp?color=64http://www.w3schools.com/html/html_colorsmore.asp?color=64http://www.w3schools.com/html/html_colorsmore.asp?color=72http://www.w3schools.com/html/html_colorsmore.asp?color=72http://www.w3schools.com/html/html_colorsmore.asp?color=80http://www.w3schools.com/html/html_colorsmore.asp?color=80http://www.w3schools.com/html/html_colorsmore.asp?color=88http://www.w3schools.com/html/html_colorsmore.asp?color=88http://www.w3schools.com/html/html_colorsmore.asp?color=96http://www.w3schools.com/html/html_colorsmore.asp?color=96http://www.w3schools.com/html/html_colorsmore.asp?color=104http://www.w3schools.com/html/html_colorsmore.asp?color=104http://www.w3schools.com/html/html_colorsmore.asp?color=112http://www.w3schools.com/html/html_colorsmore.asp?color=112http://www.w3schools.com/html/html_colorsmore.asp?color=120http://www.w3schools.com/html/html_colorsmore.asp?color=120http://www.w3schools.com/html/html_colorsmore.asp?color=128http://www.w3schools.com/html/html_colorsmore.asp?color=128http://www.w3schools.com/html/html_colorsmore.asp?color=136http://www.w3schools.com/html/html_colorsmore.asp?color=136http://www.w3schools.com/html/html_colorsmore.asp?color=144http://www.w3schools.com/html/html_colorsmore.asp?color=144http://www.w3schools.com/html/html_colorsmore.asp?color=152http://www.w3schools.com/html/html_colorsmore.asp?color=152http://www.w3schools.com/html/html_colorsmore.asp?color=160http://www.w3schools.com/html/html_colorsmore.asp?color=160http://www.w3schools.com/html/html_colorsmore.asp?color=168http://www.w3schools.com/html/html_colorsmore.asp?color=168http://www.w3schools.com/html/html_colorsmore.asp?color=176http://www.w3schools.com/html/html_colorsmore.asp?color=176http://www.w3schools.com/html/html_colorsmore.asp?color=184http://www.w3schools.com/html/html_colorsmore.asp?color=184http://www.w3schools.com/html/html_colorsmore.asp?color=192http://www.w3schools.com/html/html_colorsmore.asp?color=192http://www.w3schools.com/html/html_colorsmore.asp?color=200http://www.w3schools.com/html/html_colorsmore.asp?color=200http://www.w3schools.com/html/html_colorsmore.asp?color=208http://www.w3schools.com/html/html_colorsmore.asp?color=208http://www.w3schools.com/html/html_colorsmore.asp?color=216http://www.w3schools.com/html/html_colorsmore.asp?color=216http://www.w3schools.com/html/html_colorsmore.asp?color=224http://www.w3schools.com/html/html_colorsmore.asp?color=224http://www.w3schools.com/html/html_colorsmore.asp?color=232http://www.w3schools.com/html/html_colorsmore.asp?color=232http://www.w3schools.com/html/html_colorsmore.asp?color=240http://www.w3schools.com/html/html_colorsmore.asp?color=240http://www.w3schools.com/html/html_colorsmore.asp?color=248http://www.w3schools.com/html/html_colorsmore.asp?color=248http://www.w3schools.com/html/html_colorsmore.asp?color=255http://www.w3schools.com/html/html_colorsmore.asp?color=2558/8/2019 Htlml Tags
34/63
#303030 rgb(48,48,48)
#383838 rgb(56,56,56)
#404040 rgb(64,64,64)
#484848 rgb(72,72,72)
#505050 rgb(80,80,80)
#585858 rgb(88,88,88)
#606060 rgb(96,96,96)
#686868 rgb(104,104,104)
#707070 rgb(112,112,112)
#787878 rgb(120,120,120)
#808080 rgb(128,128,128)
#888888 rgb(136,136,136)
#909090 rgb(144,144,144)
#989898 rgb(152,152,152)
#A0A0A0 rgb(160,160,160)#A8A8A8 rgb(168,168,168)
#B0B0B0 rgb(176,176,176)
#B8B8B8 rgb(184,184,184)
#C0C0C0 rgb(192,192,192)
#C8C8C8 rgb(200,200,200)
#D0D0D0 rgb(208,208,208)
#D8D8D8 rgb(216,216,216)
#E0E0E0 rgb(224,224,224)
#E8E8E8 rgb(232,232,232)
#F0F0F0 rgb(240,240,240)#F8F8F8 rgb(248,248,248)
#FFFFFF rgb(255,255,255)
Cross-Browser Color Names
A collection of nearly 150 color names are supported by all major browsers.
View the cross-browser color names
Web Standard Color Names
The World Wide Web Consortium (W3C) has listed 16 valid color names for HTML and CSS:
aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, andyellow.
34
http://www.w3schools.com/html/html_colornames.asphttp://www.w3schools.com/html/html_colornames.asp8/8/2019 Htlml Tags
35/63
Note: Different browsers may display different colors for the same color name. "Green" can be lighter inone browser than another. To achieve the same result in all browsers, always use the HEX notation.
Web Safe Colors?
Some years ago, when computers supported max 256 different colors, a list of 216 "Web Safe Colors" wassuggested as a Web standard, reserving 40 fixed system colors.
The 216 cross-browser color palette was created to ensure that all computers would display the colorscorrectly when running a 256 color palette.
This is not important today, since most computers can display millions of different colors. Anyway, here isthe list:
000000 000033 000066 000099 0000CC 0000FF
003300 003333 003366 003399 0033CC 0033FF
006600 006633 006666 006699 0066CC 0066FF
009900 009933 009966 009999 0099CC 0099FF
00CC00 00CC33 00CC66 00CC99 00CCCC 00CCFF
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF
330000 330033 330066 330099 3300CC 3300FF
333300 333333 333366 333399 3333CC 3333FF
336600 336633 336666 336699 3366CC 3366FF
339900 339933 339966 339999 3399CC 3399FF
33CC00 33CC33 33CC66 33CC99 33CCCC 33CCFF
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF
663300 663333 663366 663399 6633CC 6633FF
666600 666633 666666 666699 6666CC 6666FF
669900 669933 669966 669999 6699CC 6699FF
66CC00 66CC33 66CC66 66CC99 66CCCC 66CCFF
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF
990000 990033 990066 990099 9900CC 9900FF
993300 993333 993366 993399 9933CC 9933FF
996600 996633 996666 996699 9966CC 9966FF
999900 999933 999966 999999 9999CC 9999FF99CC00 99CC33 99CC66 99CC99 99CCCC 99CCFF
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF
CC0000 CC0033 CC0066 CC0099 CC00CC CC00FF
CC3300 CC3333 CC3366 CC3399 CC33CC CC33FF
CC6600 CC6633 CC6666 CC6699 CC66CC CC66FF
CC9900 CC9933 CC9966 CC9999 CC99CC CC99FF
35
8/8/2019 Htlml Tags
36/63
CCCC00 CCCC33 CCCC66 CCCC99 CCCCCC CCCCFF
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF
FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF
FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF
FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF
FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF
FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF
FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF
What is so Great About HTML 4.0?
In HTML 4.0 all formatting can be removed from the HTML document, and stored in a style sheet.
Because HTML 4.0 separates the layout from the document structure, we have what we always needed:Total control of layout, without messing up the document content.
What You Should do About it
Do NOT use presentation attributes inside your HTML elements
Start using styles! Please read ourCSS tutorial to learn about style sheets
Do NOT use deprecated tags. Visit ourHTML 4.01 Reference to see which tags and attributes thatare deprecated
Validate your HTML pages
Validate Your HTML Files
To validate an HTML document, a doctype declaration must be added.
The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version ofthe markup language the page is written in.
The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for themarkup language, so that the browsers can render the content correctly.
The doctype declaration should be the very first thing in an HTML document, before the tag.
HTML 4.01 Strict
This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational ordeprecated elements (like font). Framesets are not allowed:
36
http://www.w3schools.com/css/default.asphttp://www.w3schools.com/html/html_reference.asphttp://www.w3schools.com/html/html_reference.asphttp://www.w3schools.com/css/default.asphttp://www.w3schools.com/html/html_reference.asp8/8/2019 Htlml Tags
37/63
HTML 4.01 Transitional
This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecatedelements (like font). Framesets are not allowed:
HTML 4.01 Frameset
This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content:
Validate Your HTML With W3C's Validator
Type a URL in the input field below (like http://www.w3schools.com/):
Validate the page
HTML DOCTYPE Element
Tag Description
Defines the document type. This declaration goes before the start tag
HTML CSS:
In HTML 4.0, all formatting can be removed from the HTML document, and stored in a style sheet.
How to Use Styles
When a browser reads a style sheet, it will format the document according to it.
There are three ways of inserting a style sheet:
External style sheet
Internal style sheet
Inline styles
37
http://www.w3schools.com/tags/tag_doctype.asphttp://www.w3schools.com/tags/tag_doctype.asp8/8/2019 Htlml Tags
38/63
External Style Sheet
An external style sheet is ideal when the style is applied to many pages. With an external style sheet, youcan change the look of an entire Web site by changing one file. Each page must link to the style sheet usingthe tag. The tag goes inside the section:
Internal Style Sheet
An internal style sheet can be used if one single document has a unique style. Internal styles are defined inthe section of an HTML page, by using the tag, like this:
body {background-color:yellow}p {color:blue}
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:
This is a paragraph.
The HTML file below links to an external style sheet with the tag:
This header is 36 ptThis header is blue
This paragraph has a left margin of 50 pixels
38
8/8/2019 Htlml Tags
39/63
This is the style sheet file (ex1.css):
body{background-color:yellow;}h1{font-size:36pt;}h2{color:blue;}p{margin-left:50px;}
The result is in the frame below:
The HTML file below links to an external style sheet with the tag:
This is a header 1
You can see that the stylesheet formats the text
This is a link
This is the style sheet file (ex2.css):
body {background-color:tan;}h1 {color:maroon;font-size:20pt;}hr {color:navy;}p {font-size:11pt;margin-left:15px;}a:link {color:green;}a:visited {color:yellow;}a:hover {color:black;}a:active {color:blue;}
39
8/8/2019 Htlml Tags
40/63
CSS Syntax
A CSS rule has two main parts: a selector, and one or more declarations:
The selector is normally the HTML element you want to style.
Each declaration consists of a property and a value.
The property is the style attribute you want to change. Each property has a value.
CSS Example
CSS declarations always ends with a semicolon, and declaration groups are surrounded by curly brackets:
p {color:red;text-align:center;}
To make the CSS more readable, you can put one declaration on each line, like this:
Example
p{color:red;text-align:center;}
Try it yourself
CSS Comments
Comments are used to explain your code, and may help you when you edit the source code at a later date.Comments are ignored by browsers.
A CSS comment begins with "/*", and ends with "*/", like this:
/*This is a comment*/
40
http://www.w3schools.com/css/tryit.asp?filename=trycss_syntax1http://www.w3schools.com/css/tryit.asp?filename=trycss_syntax1http://www.w3schools.com/css/tryit.asp?filename=trycss_syntax18/8/2019 Htlml Tags
41/63
p{text-align:center;/*This is another comment*/color:black;font-family:arial;}
CSS Id and Class
The id and class Selectors
In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id"and "class".
The id Selector
The id selector is used to specify a style for a single, unique element.
The id selector uses the id attribute of the HTML element, and is defined with a "#".
The style rule below will be applied to the element with id="para1":
Example
#para1{text-align:center;color:red;}
Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.
The class Selector
The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selectoris most often used on several elements.
This allows you to set a particular style for any HTML elements with the same class.
The class selector uses the HTML class attribute, and is defined with a "."
In the example below, all HTML elements with class="center" will be center-aligned:
41
8/8/2019 Htlml Tags
42/63
Example
.center {text-align:center;}
You can also specify that only specific HTML elements should be affected by a class.
In the example below, all p elements with class="center" will be center-aligned:
Example
p.center {text-align:center;}
Do NOT start a class name with a number! This is only supported in Internet Explorer.
CSS How To...
When a browser reads a style sheet, it will format the document according to it.
Three Ways to Insert CSS
There are three ways of inserting a style sheet:
External style sheet
Internal style sheet
Inline style
External Style Sheet
An external style sheet is ideal when the style is applied to many pages. With an external style sheet, youcan change the look of an entire Web site by changing one file. Each page must link to the style sheet usingthe tag. The tag goes inside the head section:
An external style sheet can be written in any text editor. The file should not contain any html tags. Yourstyle sheet should be saved with a .css extension. An example of a style sheet file is shown below:
hr {color:sienna;}p {margin-left:20px;}body {background-image:url("images/back40.gif");}
42
8/8/2019 Htlml Tags
43/63
Do not leave spaces between the property value and the units! "margin-left:20 px" (instead of "margin-left:20px") will work in IE, but not in Firefox or Opera.
Internal Style Sheet
An internal style sheet should be used when a single document has a unique style. You define internalstyles in the head section of an HTML page, by using the tag, like this:
hr {color:sienna;}p {margin-left:20px;}body {background-image:url("images/back40.gif");}
Inline Styles
An inline style loses many of the advantages of style sheets by mixing content with presentation. Use thismethod sparingly!
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSSproperty. The example shows how to change the color and the left margin of a paragraph:
This is a paragraph.
Multiple Style Sheets
If some properties have been set for the same selector in different style sheets, the values will be inheritedfrom the more specific style sheet.
For example, an external style sheet has these properties for the h3 selector:
h3{color:red;text-align:left;font-size:8pt;
}
And an internal style sheet has these properties for the h3 selector:
h3{text-align:right;font-size:20pt;}
43
8/8/2019 Htlml Tags
44/63
If the page with the internal style sheet also links to the external style sheet the properties for h3 will be:
color:red;text-align:right;font-size:20pt;
The color is inherited from the external style sheet and the text-alignment and the font-size is replaced bythe internal style sheet.
Multiple Styles Will Cascade into One
Styles can be specified:
inside an HTML element
inside the head section of an HTML page
in an external CSS file
Tip: Even multiple external style sheets can be referenced inside a single HTML document.
Cascading order
What style will be used when there is more than one style specified for an HTML element?
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by thefollowing rules, where number four has the highest priority:
1. Browser default2. External style sheet3. Internal style sheet (in the head section)4. Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it will override astyle defined inside the tag, or in an external style sheet, or in a browser (a default value).
Note: If the link to the external style sheet is placed after the internal style sheet in HTML , theexternal style sheet will override the internal style sheet!
CSS Background
CSS background properties are used to define the background effects of anelement.
CSS properties used for background effects:
background-color
background-image
background-repeat
44
8/8/2019 Htlml Tags
45/63
background-attachment
background-position
Background Color
The background-color property specifies the background color of an element.
The background color of a page is defined in the body selector:
Example
body {background-color:#b0c4de;}
The background color can be specified by:
name - a color name, like "red" RGB - an RGB value, like "rgb(255,0,0)"
Hex - a hex value, like "#ff0000"
In the example below, the h1, p, and div elements have different background colors:
Example
h1 {background-color:#6495ed;}p {background-color:#e0ffff;}div {background-color:#b0c4de;}
Background Image
The background-image property specifies an image to use as the background of an element.
By default, the image is repeated so it covers the entire element.
The background image for a page can be set like this:
Example
body {background-image:url('paper.gif');}
Below is an example of a bad combination of text and background image. The text is almost not readable:
45
8/8/2019 Htlml Tags
46/63
Example
body {background-image:url('bgdesert.jpg');}
Background Image - Repeat Horizontally or Vertically
By default, the background-image property repeats an image both horizontally and vertically.
Some images should be repeated only horizontally or vertically, or they will look strange, like this:
Example
body{background-image:url('gradient2.png');}
If the image is repeated only horizontally (repeat-x), the background will look better:
Example
body{background-image:url('gradient2.png');background-repeat:repeat-x;}
Background Image - Set position and no-repeat
When using a background image, use an image that does not disturb the text.
Showing the image only once is specified by the background-repeat property:
Examplebody{background-image:url('img_tree.png');background-repeat:no-repeat;}
46
8/8/2019 Htlml Tags
47/63
In the example above, the background image is shown in the same place as the text. We want to change theposition of the image, so that it does not disturb the text too much.
The position of the image is specified by the background-position property:
Examplebody{background-image:url('img_tree.png');background-repeat:no-repeat;background-position:right top;}
Background - Shorthand property
As you can see from the examples above, there are many properties to consider when dealing withbackgrounds.
To shorten the code, it is also possible to specify all the properties in one single property. This is called ashorthand property.
The shorthand property for background is simply "background":
Example
body {background:#ffffff url('img_tree.png') no-repeat right top;}
When using the shorthand property the order of the property values are:
background-color
background-image
background-repeat
background-attachment
background-position
It does not matter if one of the property values are missing, as long as the ones that are present are in thisorder.
All CSS Background Properties
The number in the "CSS" column indicates in which CSS version the property is defined (CSS1 or CSS2).
47
8/8/2019 Htlml Tags
48/63
Property Description Values CSS
backgroundSets all the background properties inone declaration
background-color
background-image
background-repeat
background-attachmentbackground-position
inherit
1
background-attachmentSets whether a background image isfixed or scrolls with the rest of thepage
scrollfixedinherit
1
background-colorSets the background color of anelement
color-rgbcolor-hex
color-nametransparentinherit
1
background-imageSets the background image for anelement
url(URL)noneinherit
1
background-positionSets the starting position of abackground image
left topleft centerleft bottomright topright centerright bottomcenter topcenter centercenter bottom
x% y%
xpos yposinherit
1
background-repeat Sets if/how a background image willbe repeated
repeat
repeat-xrepeat-yno-repeatinherit
1
CSS Text
TEXT FORMATTING
T h i s t e x t i s s t y l ed w i t h s o m e o f t h e t e x t f o r m a t t i n g p r o p e r t i e s .
T h e h e a d i n g u s e s t h e t e x t - a l i g n , t e x t - t r a n s f o r m , a n d c o l o r p r o p e r t i e s .T h e p a r a g r a p h i s i n d e n t e d , a l i g n e d , a n d t h e s p a c e b e t w e e n c h a r a c t e r s i ss p e c i f i e d . T h e u n d e r l i n e i s r e m o v e d f r o m t h e " T r y i t y o u r s e l f " l i n k .
Text Color
The color property is used to set the color of the text. The color can be specified by:
48
http://www.w3schools.com/css/pr_background.asphttp://www.w3schools.com/css/pr_background-attachment.asphttp://www.w3schools.com/css/pr_background-color.asphttp://www.w3schools.com/css/pr_background-image.asphttp://www.w3schools.com/css/pr_background-position.asphttp://www.w3schools.com/css/pr_background-repeat.asphttp://www.w3schools.com/css/tryit.asp?filename=trycss_texthttp://www.w3schools.com/css/pr_background.asphttp://www.w3schools.com/css/pr_background-attachment.asphttp://www.w3schools.com/css/pr_background-color.asphttp://www.w3schools.com/css/pr_background-image.asphttp://www.w3schools.com/css/pr_background-position.asphttp://www.w3schools.com/css/pr_background-repeat.asphttp://www.w3schools.com/css/tryit.asp?filename=trycss_text8/8/2019 Htlml Tags
49/63
name - a color name, like "red"
RGB - an RGB value, like "rgb(255,0,0)"
Hex - a hex value, like "#ff0000"
The default color for a page is defined in the body selector.
Example
body {color:blue;}h1 {color:#00ff00;}h2 {color:rgb(255,0,0);}
For W3C compliant CSS: If you define the color property, you must also define the background-colorproperty.
Text Alignment
The text-align property is used to set the horizontal alignment of a text.
Text can be centered, or aligned to the left or right, or justified.
When text-align is set to "justify", each line is stretched so that every line has equal width, and the left andright margins are straight (like in magazines and newspapers).
Example
h1 {text-align:center;}p.date {text-align:right;}p.main {text-align:justify;}
Text Decoration
The text-decoration property is used to set or remove decorations from text.
The text-decoration property is mostly used to remove underlines from links for design purposes:
Example
a {text-decoration:none;}
49
8/8/2019 Htlml Tags
50/63
It can also be used to decorate text:
Example
h1 {text-decoration:overline;}
h2 {text-decoration:line-through;}h3 {text-decoration:underline;}h4 {text-decoration:blink;}
It is not recommended to underline text that is not a link, as this often confuses users.
Text Transformation
The text-transform property is used to specify uppercase and lowercase letters in a text.
It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of eachword.
Example
p.uppercase {text-transform:uppercase;}p.lowercase {text-transform:lowercase;}p.capitalize {text-transform:capitalize;}
Text Indentation
The text-indentation property is used to specify the indentation of the first line of a text.
Example
p {text-indent:50px;}
CSS Font
CSS font properties define the font family, boldness, size, and the style of a text.
Difference Between Serif and Sans-serif Fonts
50
8/8/2019 Htlml Tags
51/63
On computer screens, sans-serif fonts are considered easier to read than serif fonts.
CSS Font Families
In CSS, there are two types of font family names:
generic family - a group of font families with a similar look (like "Serif" or "Monospace")
font family - a specific font family (like "Times New Roman" or "Arial")
Generic family Font family Description
SerifTimes New RomanGeorgia
Serif fonts have small lines at the ends on somecharacters
Sans-serifArial
Verdana
"Sans" means without - these fonts do not have thelines at the ends of characters
MonospaceCourier New
Lucida ConsoleAll monospace characters have the same width
Font Family
The font family of a text is set with the font-family property.
The font-family property should hold several font names as a "fallback" system. If the browser does notsupport the first font, it tries the next font.
Start with the font you want, and end with a generic family, to let the browser pick a similar font in thegeneric family, if no other fonts are available.
Note: If the name of a font family is more than one word, it must be in quotation marks, like font-family:"Times New Roman".
More than one font family is specified in a comma-separated list:
Example
p{font-family:"Times New Roman", Times, serif;}
51
8/8/2019 Htlml Tags
52/63
Font Style
The font-style property is mostly used to specify italic text.
This property has three values:
normal - The text is shown normally
italic - The text is shown in italics
oblique - The text is "leaning" (oblique is very similar to italic, but less supported)
Example
p.normal {font-style:normal;}p.italic {font-style:italic;}p.oblique {font-style:oblique;}
Font Size
The font-size property sets the size of the text.
Being able to manage the text size is important in web design. However, you should not use font sizeadjustments to make paragraphs look like headings, or headings look like paragraphs.
Always use the proper HTML tags, like - for headings and
for paragraphs.
The font-size value can be an absolute, or relative size.
Absolute size:
Sets the text to a specified size
Does not allow a user to change the text size in all browsers (bad for accessibility reasons)
Absolute size is useful when the physical size of the output is known
Relative size:
Sets the size relative to surrounding elements
Allows a user to change the text size in browsers
If you do not specify a font size, the default size for normal text, like paragraphs, is 16px (16px=1em).
Set Font Size With Pixels
Setting the text size with pixels, gives you full control over the text size:
52
8/8/2019 Htlml Tags
53/63
Example
h1 {font-size:40px;}h2 {font-size:30px;}p {font-size:14px;}
The example above allows Firefox, Chrome, and Safari to resize the text, but not Internet Explorer.
The text can be resized in all browsers using the zoom tool (however, this resizes the entire page, not justthe text).
Set Font Size With Em
To avoid the resizing problem with Internet Explorer, many developers use em instead of pixels.
The em size unit is recommended by the W3C.
1em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is16px.
The size can be calculated from pixels to em using this formula:pixels/16=em
Example
h1 {font-size:2.5em;} /* 40px/16=2.5em */h2 {font-size:1.875em;} /* 30px/16=1.875em */
p {font-size:0.875em;} /* 14px/16=0.875em */
In the example above, the text size in em is the same as the previous example in pixels. However, with theem size, it is possible to adjust the text size in all browsers.
Unfortunately, there is still a problem with IE. When resizing the text, it becomes larger than it shouldwhen made larger, and smaller than it should when made smaller.
Use a Combination of Percent and EmThe solution that works in all browsers, is to set a default font-size in percent for the body element:
Example
body {font-size:100%;}h1 {font-size:2.5em;}h2 {font-size:1.875em;}
53
8/8/2019 Htlml Tags
54/63
p {font-size:0.875em;}
All CSS Font Properties
The number in the "CSS" column indicates in which CSS version the property is defined (CSS1 or CSS2).
Property Description Values CSS
font Sets all the font properties in one declaration
font-style
font-variant
font-weight
font-size/line-height
font-family
captioniconmenumessage-box
small-captionstatus-barinherit
1
font-family Specifies the font family for textfamily-name
generic-familyinherit
1
font-size Specifies the font size of text
xx-smallx-smallsmallmediumlargex-largexx-largesmallerlargerlength
%inherit
1
font-style Specifies the font style for text
normalitalicobliqueinherit
1
font-variantSpecifies whether or not a text should bedisplayed in a small-caps font
normalsmall-capsinherit
1
font-weight Specifies the weight of a font normalboldbolderlighter100200300400500
54
http://www.w3schools.com/css/pr_font_font.asphttp://www.w3schools.com/css/pr_font_font-family.asphttp://www.w3schools.com/css/pr_font_font-size.asphttp://www.w3schools.com/css/pr_font_font-style.asphttp://www.w3schools.com/css/pr_font_font-variant.asphttp://www.w3schools.com/css/pr_font_weight.asphttp://www.w3schools.com/css/pr_font_font.asphttp://www.w3schools.com/css/pr_font_font-family.asphttp://www.w3schools.com/css/pr_font_font-size.asphttp://www.w3schools.com/css/pr_font_font-style.asphttp://www.w3schools.com/css/pr_font_font-variant.asphttp://www.w3schools.com/css/pr_font_weight.asp8/8/2019 Htlml Tags
55/63
600700800900inherit
CSS Links
Links can be styled in different ways.
Styling Links
Links can be styled with any CSS property (e.g. color, font-family, background, etc.).
Special for links are that they can be styled differently depending on what state they are in.
The four links states are:
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it
a:active - a link the moment it is clicked
Example
a:link {color:#FF0000;} /* unvisited link */a:visited {color:#00FF00;} /* visited link */a:hover {color:#FF00FF;} /* mouse over link */a:active {color:#0000FF;} /* selected link */
When setting the style for several link states, there are some order rules:
a:hover MUST come after a:link and a:visited
a:active MUST come after a:hover
Common Link Styles
In the example above the link changes color depending on what state it is in.
Lets go through some of the other common ways to style links:
Text Decoration
55
8/8/2019 Htlml Tags
56/63
The text-decoration property is mostly used to remove underlines from links:
Example
a:link {text-decoration:none;}
a:visited {text-decoration:none;}a:hover {text-decoration:underline;}a:active {text-decoration:underline;}
Background Color
The background-color property specifies the background color for links:
Example
a:link {background-color:#B2FF99;}a:visited {background-color:#FFFF85;}a:hover {background-color:#FF704D;}a:active {background-color:#FF704D;}
CSS Lists
The CSS list properties allow you to:
Set different list item markers for ordered lists
Set different list item markers for unordered lists
Set an image as the list item marker
List
In HTML, there are two types of lists:
unordered lists - the list items are marked with bullets
ordered lists - the list items are marked with numbers or letters
With CSS, lists can be styled further, and images can be used as the list item marker.
Different List Item Markers
The type of list item marker is specified with the list-style-type property:
56
8/8/2019 Htlml Tags
57/63
Example
ul.a {list-style-type: circle;}ul.b {list-style-type: square;}
ol.c {list-style-type: upper-roman;}ol.d {list-style-type: lower-alpha;}
Some of the property values are for unordered lists, and some for ordered lists.
Values for Unordered Lists
Value Description
none No marker
disc Default. The marker is a filled circle
circle The marker is a circle
square The marker is a square
Values for Ordered Lists
Value Description
armenian The marker is traditional Armenian numbering
decimal The marker is a number
decimal-leading-zero The marker is a number padded by initial zeros (01, 02, 03, etc.)
georgian The marker is traditional Georgian numbering (an, ban, gan, etc.)
lower-alpha The marker is lower-alpha (a, b, c, d, e, etc.)lower-greek The marker is lower-greek (alpha, beta, gamma, etc.)
lower-latin The marker is lower-latin (a, b, c, d, e, etc.)
lower-roman The marker is lower-roman (i, ii, iii, iv, v, etc.)
upper-alpha The marker is upper-alpha (A, B, C, D, E, etc.)
upper-latin The marker is upper-latin (A, B, C, D, E, etc.)
upper-roman The marker is upper-roman (I, II, III, IV, V, etc.)
Note: No versions of Internet Explorer (including IE8) support the property values "decimal-leading-zero", "lower-greek", "lower-latin", "upper-latin", "armenian", or "georgian" UNLESS a DOCTYPE isspecified!
An Image as The List Item Marker
To specify an image as the list item marker, use the list-style-image property:
Example
57
8/8/2019 Htlml Tags
58/63
ul{list-style-image: url('sqpurple.gif');}
The example above does not display equally in all browsers. IE and Opera will display the image-marker alittle bit higher than Firefox, Chrome, and Safari.
If you want the image-marker to be placed equally in all browsers, a crossbrowser solution is explainedbelow.
Crossbrowser Solution
The following example displays the image-marker equally in all browsers:
Exampleul{list-style-type: none;padding: 0px;margin: 0px;}li{background-image: url(sqpurple.gif);background-repeat: no-repeat;background-position: 0px 5px;padding-left: 14px;}
Example explained:
For ul:o Set the list-style-type to none to remove the list item marker
o Set both padding and margin to 0px (for cross-browser compatibility)
For li:o Set the URL of the image, and show it only once (no-repeat)
o Position the image where you want it (left 0px and down 5px)
o Position the text in the list with padding-left
List - Shorthand property
It is also possible to specify all the list properties in one, single property. This is called a shorthandproperty.
58
8/8/2019 Htlml Tags
59/63
The shorthand property used for lists, is the list-style property:
Example
ul
{list-style: square url("sqpurple.gif");}
Try it yourself
When using the shorthand property, the order of the values are:
list-style-type
list-style-position (for a description, see the CSS properties table below)
list-style-image
It does not matter if one of the values above are missing, as long as the rest are in the specified order.
all the different list-item markers in CSS.
All CSS List Properties
The number in the "CSS" column indicates in which CSS version the property is defined (CSS1 or CSS2).
Property Description Values CSS
list-style Sets all the properties for a list in one declaration
list-style-type
list-style-position
list-style-imageinherit
1
list-style-image Specifies an image as the list-item markerURLnoneinherit
1
list-style-positionSpecifies if the list-item markers should appearinside or outside the content flow
insideoutsideinherit
1
list-style-type Specifies the type of list-item marker nonedisccirclesquare
decimaldecimal-leading-zeroarmeniangeorgianlower-alphaupper-alphalower-greeklower-latinupper-latinlower-roman
1
59
http://www.w3schools.com/css/tryit.asp?filename=trycss_list-stylehttp://www.w3schools.com/css/tryit.asp?filename=trycss_list-stylehttp://www.w3schools.com/css/pr_list-style.asphttp://www.w3schools.com/css/pr_list-style-image.asphttp://www.w3schools.com/css/pr_list-style-position.asphttp://www.w3schools.com/css/pr_list-style-type.asphttp://www.w3schools.com/css/tryit.asp?filename=trycss_list-stylehttp://www.w3schools.com/css/pr_list-style.asphttp://www.w3schools.com/css/pr_list-style-image.asphttp://www.w3schools.com/css/pr_list-style-position.asphttp://www.w3schools.com/css/pr_list-style-type.asp8/8/2019 Htlml Tags
60/63
upper-romaninherit
CSS TablesThe look of an HTML table can be greatly improved with CSS:
Company Contact Country
Alfreds Futterkiste Maria Anders Germany
Berglunds snabbkp Christina Berglund Sweden
Centro comercial Moctezuma Francisco Chang Mexico
Ernst Handel Roland Mendel Austria
Island Trading Helen Bennett UK
Kniglich Essen Philip Cramer Germany
Laughing Bacchus Winecellars Yoshi Tannamuri Canada
Magazzini Alimentari Riuniti Giovanni Rovelli ItalyNorth/South Simon Crowther UK
Paris spcialits Marie Bertrand France
The Big Cheese Liz Nixon USA
Vaffeljernet Palle Ibsen Denmark
Table Borders
To specify table borders in CSS, use the border property.
The example below specifies a black border for table, th, and td elements:
Example
table, th, td{border: 1px solid black;}
Notice that the table in the example above has double borders. This is because both the table, th, and tdelements have separate borders.
To display a single border for the table, use the border-collapse property.
Collapse Borders
The border-collapse property sets whether the table borders are collapsed into a single border or separated:
Example
60
8/8/2019 Htlml Tags
61/63
table{border-collapse:collapse;}table,th, td{border: 1px solid black;}
Table Width and Height
Width and height of a table is defined by the width and height properties.
The example below sets the width of the table to 100%, and the height of the th elements to 50px:
Example
table{width:100%;}th{height:50px;}
Table Text Alignment
The text in a table is aligned with the text-align and vertical-align properties.
The text-align property sets the horizontal alignment, like left, right, or center:
Example
td{text-align:right;}
The vertical-align property sets the vertical alignment, like top, bottom, or middle:
61
8/8/2019 Htlml Tags
62/63
Example
td{height:50px;vertical-align:bottom;}
Table Padding
To control the space between the border and content in a table, use the padding property on td and thelements:
Example
td{padding:15px;}
Table Color
The example below specifies the color of the borders, and the text and background color of th elements:
Example
table, td, th{border:1px solid green;}th{background-color:green;color:white;}
Make a Fancy Table:
body{
62
8/8/2019 Htlml Tags
63/63
margin-left:200px;background:#5d9ab2 url('img_tree.png') no-repeat top left;}
.container{text-align:center;}
.center_div{border:1px solid gray;margin-left:auto;margin-right:auto;width:90%;background-color:#d0f0f6;text-align:left;padding:8px;}
Hello World!
This example contains some advanced CSS methods you may not have learned yet. But, we willexplain these methods in a later chapter in the tutorial.