Basic of HTML
Basic of HTML
1
8 [CREATING A WEBPAGE WITH HTML AND CSS]
CONTENTS
B HISTORY of WEBSITE................................................................................................................................... 5
C OVERVIEW...................................................................................................................................................... 6
D STATIC WEBSITE........................................................................................................................................... 6
a What is HTML?............................................................................................................................................ 8
B HTML ELEMENTS........................................................................................................................................ 10
a HTML Tags................................................................................................................................................. 10
b HTML Elements......................................................................................................................................... 10
a Headings...................................................................................................................................................... 10
b Paragraphs.................................................................................................................................................... 11
c Line breaks................................................................................................................................................... 11
E HTML FONTS................................................................................................................................................. 11
F HTML LISTS.................................................................................................................................................. 12
a Ordered Lists............................................................................................................................................... 12
b Unordered Lists........................................................................................................................................... 12
2
[CREATING A WEBPAGE WITH HTML AND CSS] 8
c Defenition Lists........................................................................................................................................... 13
G HTML Images................................................................................................................................................. 13
H HTML BACKGROUNDS.............................................................................................................................. 14
a Background Color....................................................................................................................................... 14
b Background Image...................................................................................................................................... 14
a WHAT IS CSS?.......................................................................................................................................... 15
b CSS DEMO................................................................................................................................................. 15
B CSS SYNTAX................................................................................................................................................. 17
a Id Selector................................................................................................................................................... 18
b Class Selector.............................................................................................................................................. 18
c Inline Styles................................................................................................................................................. 19
a Text Color................................................................................................................................................... 20
3
8 [CREATING A WEBPAGE WITH HTML AND CSS]
b Text Alignment........................................................................................................................................... 20
c Text Decoration.......................................................................................................................................... 20
d Text Transformation................................................................................................................................... 21
F CSS FONT....................................................................................................................................................... 21
b Font Family................................................................................................................................................ 22
c Font Style................................................................................................................................................... 22
d Font Size..................................................................................................................................................... 22
G CSS LIST........................................................................................................................................................ 23
d Crossbrowser solution................................................................................................................................ 24
H CSS BACKGROUND.................................................................................................................................... 25
a Bcakground Color...................................................................................................................................... 25
b Background Image..................................................................................................................................... 25
REFERENCE PAGES.............................................................................................27
BIBLIOGRAPHY...................................................................................................31
4
[CREATING A WEBPAGE WITH HTML AND CSS] 8
CHAPTER I: WEBS
ITE
A INTRODUCTION OF WEBSITE
A website (also spelled web site) is a collection of related web pages, All publicly
images, videos or other digital assets that are addressed with a common domain
name or IP address in an Internet Protocol-based network. A web site is hosted accessible websites
on at least one web server, accessible via a network such as the Internet or a
private local area network. collectively
constitute the
A web page is a document, typically written in plain text interspersed
with formatting instructions of Hypertext Markup Language (HTML, XHTML).
A web page may incorporate elements from other websites with suitable
markup anchors.
Web pages are accessed and transported with the Hypertext Transfer Protocol (HTTP), which may optionally
employ encryption (HTTP Secure, HTTPS) to provide security and privacy for the user of the web page content.
The user's application, often a web browser, renders the page content according to its HTML markup instructions
onto a display terminal.
The pages of a website can usually be accessed from a simple Uniform Resource Locator (URL) called the
homepage. The URLs of the pages organize them into a hierarchy, although hyper linking between them conveys the
reader's perceived site structure and guides the reader's navigation of the site.
Some websites require a subscription to access some or all of their content. Examples of subscription sites
include many business sites, parts of many news sites, academic journal sites, gaming sites, message boards, web-
based e-mail, services, social networking websites, and sites providing real-time stock market data.
B HISTORY OF WEBSITE
The World Wide Web was created in 1990 by CERN engineer Tim Berners-Lee. On 30 April 1993, CERN
announced that the World Wide Web would be free to use for anyone.
5
8 [CREATING A WEBPAGE WITH HTML AND CSS]
Before the introduction of HTML and HTTP, other protocols such as file transfer protocol and the gopher
protocol were used to retrieve individual files from a server. These protocols offer a simple directory structure which
the user navigates and chooses files to download. Documents were most often presented as plain text files without
formatting or were encoded in word processor formats.
A website is hosted on a computer system known as a web server, also called an HTTP server, and these
terms can also refer to the software that runs on these systems and that retrieves and delivers the web pages in
response to requests from the website users. Apache is the most commonly used web server software (according to
Net craft statistics) and Microsoft's Internet Information Server (IIS) is also commonly used.
D STATIC WEBSITE
A static website is one that has web pages stored on the server in the format that is sent to a client web
browser. It is primarily coded in Hypertext Markup Language (HTML).
Simple forms or marketing examples of websites, such as classic website, a five-page website or a brochure
website are often static websites, because they present pre-defined, static information to the user. This may include
information about a company and its products and services via text, photos, animations, audio/video and interactive
menus and navigation.
6
[CREATING A WEBPAGE WITH HTML AND CSS] 8
This type of website usually displays the same information to all visitors. Similar to handing out a printed
brochure to customers or clients, a static website will generally provide consistent, standard information for an
extended period of time. Although the website owner may make updates periodically, it is a manual process to edit
the text, photos and other content and may require basic website design skills and software.
In summary, visitors are not able to control what information they receive via a static website, and must
instead settle for whatever content the website owner has decided to offer at that time.
Text editors, such as Notepad or Text Edit, where content and HTML markup are manipulated
directly within the editor program
WYSIWYG offline editors, such as Microsoft FrontPage and Adobe Dreamweaver (previously
Macromedia Dreamweaver), with which the site is edited using a GUI interface and the final HTML
markup is generated automatically by the editor software
WYSIWYG online editors which create media rich online presentation like web pages, widgets, intro,
blogs, and other documents.
Template-based editors, such as Rapidweaver and iWeb, which allow users to quickly create and
upload web pages to a web server without detailed HTML knowledge, as they pick a suitable
template from a palette and add pictures and text to it in a desktop publishing fashion without direct
manipulation of HTML code.
7
8 [CREATING A WEBPAGE WITH HTML AND CSS]
A WHAT IS HTML?
HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language. HTML is
not a programming language, it is a markup language. A markup language is a set of markup tags. HTML
uses markup tags to describe web pages.
In OSX start TextEdit and change the following preferences: Open the "Format" menu and select "Plain text"
instead of "Rich text". Then open the "Preferences" window under the "Text Edit" menu and select "Ignore rich
text commands in HTML files". Your HTML code will probably not work if you do not change the preferences
above!
8
[CREATING A WEBPAGE WITH HTML AND CSS] 8
“Save the file as "mypage.htm". Start your Internet browser. Select "Open" (or "Open Page") in the File menu of
your browser. A dialog box will appear. Select "Browse" (or "Choose File") and locate the HTML file you just
created - "mypage.htm" - select it and click "Open". Now you should see an address in the dialog box, for example
"C:\MyDocuments\mypage.htm". Click OK, and the browser will display the page as seen below.”
9
8 [CREATING A WEBPAGE WITH HTML AND CSS]
The first tag in your HTML document is <html>. This tag tells your browser that this is the start of an
HTML document. The last tag in your document is </html>. This tag tells your browser that this is the end
of the HTML document.
The text between the <head> tag and the </head> tag is header information. Header information is not
displayed in the browser window.
The text between the <title> tags is the title of your document. The title is displayed in your browser's
caption.
The text between the <body> tags is the text that will be displayed in your browser.
The text between the <b> and </b> tags will be displayed in a bold font.
When you save an HTML file, you can use either the .htm or the .html extension. We have used .htm
in our examples. It might be a bad habit inherited from the past when some of the commonly used
software only allowed three letter extensions.
B HTML ELEMENTS
10
[CREATING A WEBPAGE WITH HTML AND CSS] 8
HTML documents are text files made up of HTML elements. HTML elements are defined using HTML
tags.
A HTML TAGS
HTML tags are used to mark-up HTML elements.
HTML tags are surrounded by the two characters < and >.
The surrounding characters are called angle brackets.
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 text between the start and end tags is the element content.
HTML tags are not case sensitive; <b> means the same as <B>.
B HTML ELEMENTS
*NOTE:
The purpose of the <b> tag is to define
an HTML element that should be
displayed as bold.
The purpose of the <body> tag is to define the HTML element that contains the body of the HTML document.
The most important tags in HTML are tags that define headings, paragraphs and line breaks.
A HEADINGS
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6> defines the smallest
heading.
HTML automatically adds an extra blank line before and after a heading.
B PARAGRAPHS
11
8 [CREATING A WEBPAGE WITH HTML AND CSS]
Paragraphs are defined with the <p> tag. HTML automatically adds an extra blank line before and after a
paragraph.
You might have noticed that paragraphs can be written without end tags </p>.
Although it will work in most browsers, but don't rely on it. Future version of HTML will not allow you to skip
ANY end tags. Closing all HTML elements with an end tag is a future-proof way of writing HTML. It also
makes the code easier to understand (read and browse) when you mark both where an element starts and where
it ends.
C LINE BREAKS
The <br> tag is used when you want to break a line, but don't want to start a new paragraph. The <br> tag
forces a line break wherever you place it. The <br> tag is an empty tag. It has no end tag like </br>, since a
closing tag doesn't make any sense.
HTML defines a lot of elements for formatting output, like bold or italic text.
Tag Description
12
[CREATING A WEBPAGE WITH HTML AND CSS] 8
E HTML FONTS
With HTML <font> tag, you can specify both the size and the type of the browser output.
<p><font size=”size of the font” face=”name of the font” color=”color name”> TEXT
</font></p>
“Size” defines the font size , “face” defines the font name, and “color” defines the font color.
F HTML LISTS
A ORDERED LISTS
An ordered list is a list of items. The list items are marked with numbers. An ordered list starts with the <ol>
tag. Each list item starts with the <li> tag.
13
8 [CREATING A WEBPAGE WITH HTML AND CSS]
B UNORDERED LISTS
An unordered list is also a list of items. The list items are marked with bullets (typically small black circles).
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
C DEFENITION LISTS
A definition list is not a list of items. This is a list of terms and explanation of the terms. A definition list starts
with the <dl> tag. Each definition-list term starts with the <dt> tag. Each definition-list definition starts with
the <dd> tag.
G HTML IMAGES
14
[CREATING A WEBPAGE WITH HTML AND CSS] 8
In HTML, images are defined with the <img> tag. The <img> tag is empty, which means that it contains
attributes only and it 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 on your page.
The browser puts the image where the image tag occurs in the document. If you put an image tag between two
paragraphs, the browser shows the first paragraph, then the image, and then the second paragraph.
The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. The
browser will then display the alternate text instead of the image. It is a good practice to include the "alt"
attribute for each image on a page, to improve the display and usefulness of your document for people who
have text-only browsers.
H HTML BACKGROUNDS
The <body> tag has two attributes where you can specify backgrounds. The background can be a color or an
image.
A BACKGROUND COLOR
The bgcolor attribute specifies a background-color for an HTML page. The value of this attribute can be a
hexadecimal number, an RGB value, or a color name:
15
<body bgcolor=”name of the color”>
8 [CREATING A WEBPAGE WITH HTML AND CSS]
B BACKGROUND IMAGE
The background attribute specifies a background-image for an HTML page. The value of this attribute is the
URL of the image you want to use. If the image is smaller than the browser window, the image will repeat
itself until it fills the entire browser window.
A WHAT IS CSS?
CSS stands for Cascading Style Sheets. Styles define how to display HTML elements. Styles are normally
stored in Style Sheets. Styles were added to HTML 4.0 to solve a problem. External Style Sheets can save
you a lot of work. External Style Sheets are stored in CSS files. Multiple style definitions will cascade into
one.
B CSS DEMO
With CSS, your HTML documents can be displayed using different output styles:
16
[CREATING A WEBPAGE WITH HTML AND CSS] 8
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
the following rules, where number four has the highest priority:
1. Browser default
2. External style sheet
3. Internal style sheet (inside the <head> tag)
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 a style declared inside the <head> tag, in an external style sheet, or in a browser
(a default value).
CSS offers much more flexibility in terms of the presentation effects that they provide. Properties such as
color, background, margin, border and many more can be applied to all elements.
Completely consistent with the look and feel of your pages.
More control over the layout and design.
Pages download faster, sometimes by as much as 50%.
You have to type less code, and your pages are shorter and neater.
17
8 [CREATING A WEBPAGE WITH HTML AND CSS]
In OSX start TextEdit and change the following preferences: Open the "Format" menu and select "Plain text"
instead of "Rich text". Then open the "Preferences" window under the "Text Edit" menu and select "Ignore rich
text commands in HTML files". Your HTML code will probably not work if you do not change the preferences
above!
B CSS SYNTAX
The CSS syntax is made up of three parts: a selector, a property and a value:
The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to
change, and each property can take a value. The property and value are separated by a colon, and surrounded
by curly braces.
FOR EXAMPLE:
If you wish to specify more than one property, you must separate each property with a semicolon. The
example below shows how to define a center aligned paragraph, with a red text color:
P {text-align:center;color:red}
In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id"
and "class".
A 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 "#".
For example, the style rule below will be applied to the element with id="para1":
#para1 {text-align:center;color:red}
B CLASS SELECTOR
The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector
is 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:
.center {text-align:center}
You can also specify that only specific HTML elements should be affected by a class.
p.center {text-align:center}
Do NOT start a class name with a number! This is only supported in Internet Explorer.
19
8 [CREATING A WEBPAGE WITH HTML AND CSS]
When a browser reads a style sheet, it will format the document according to it.
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.
An
external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet
should be saved with a .css extension. An example of a style sheet file is shown below:
An internal style sheet should be used when a single document has a unique style. You define internal styles in
the head section of an HTML page, by using the <style> tag, like this:
C INLINE STYLES
An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this
method sparingly!
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS
property. The example shows how to change the color and the left margin of a paragraph:
20
[CREATING A WEBPAGE WITH HTML AND CSS] 8
If some properties have been set for the same selector in different style sheets, the values will be inherited from
the more specific style sheet.
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 the
following rules, where number four has the highest priority:
1. Browser default
2. External style sheet
3. 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 a style
defined inside the <head> 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 <head>, the external style sheet will
override the internal style sheet!
A TEXT COLOR
The color property is used to set the color of the text. The 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"
The default color for a page is defined in the body selector.
{color: name/RGB/HEX}
B 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 and right margins are straight (like in magazines and newspapers).
{Text-align: left/center/right/justify}
21
8 [CREATING A WEBPAGE WITH HTML AND CSS]
C 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.
D 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 each word.
{text-transform: none/uppercase/lowercase/capitalize}
F CSS FONT
CSS font properties define the font family, boldness, size, and the style of a text.
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")
22
[CREATING A WEBPAGE WITH HTML AND CSS] 8
B 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 not support 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 the generic family, if no
other fonts are available.
C FONT STYLE
{font-style: normal/oblique/italic}
D 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 size
adjustments to make paragraphs look like headings, or headings look like paragraphs. Always use the proper
HTML tags, like <h1> - <h6> for headings and <p> 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).
23
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 just the
text).
G CSS LIST
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.
{list-style-type: value;}
24
[CREATING A WEBPAGE WITH HTML AND CSS] 8
C
AN IMAGE AS THE ITEM MARKER
To specify an image as the list item marker, use the list-style-image property:
The example above does not display equally in all browsers. IE and Opera will display the image-marker a
little bit higher than Firefox, Chrome, and Safari.
D CROSSBROWSER SOLUTION
25
8 [CREATING A WEBPAGE WITH HTML AND CSS]
H CSS BACKGROUND
A BCAKGROUND COLOR
The background-color property specifies the background color of an element. The background color of a page
is defined in the body selector.
26
[CREATING A WEBPAGE WITH HTML AND CSS] 8
B 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.
27
8 [CREATING A WEBPAGE WITH HTML AND CSS]
REFERENCE
PAGES
28
[CREATING A WEBPAGE WITH HTML AND CSS] 8
29
8 [CREATING A WEBPAGE WITH HTML AND CSS]
BIBLIOGRAPHY
Santos, Amelita M. (2006). Web Design and CSS. Retrieved January 10, 2010, from http://www.scribd.com
The Simple Way to Create a Website. Retrived January 07, 2010, from http:// www.4shared.com
30