Html5.o CSS
Html5.o CSS
INTERNET
A website is a series of files that display in a public network called the Internet.
The files of a website share a computer location and are accessed by other
computers on that big network.
<html></html>
HTML 5.0
HTML
HTML elements are created from tags. When a webpage displays, the browser
creates a list of elements. The list resembles a tree. The tree has a root, the root
has branches. Some branches have sub-branches that are also considered
branches. A root can have a leaf. Most branches have leaves. In a computer
application, the root is the monitor (in reality, the operating system influences the
resolution set on the monitor, but we will get into that because we don't need all
that headache at this time).
On a webpage and in HTML, the parent is the body element. All the other
elements are created directly or indirectly in that body element. Here is an
example:
HTML 5.0
In the body, you can put anything you want to display to the visitor.
<html></html>
HTML 5.0
HTML
If you want webpage to follow the current standards of CSS, you should
start its first line with:
<!DOCTYPE html>
<html>
<body></body>
</html>
HTML 5.0
HTML
<html>
<head></head>
<body></body>
</html>
HTML 5.0
HTML
<html>
<head>
<title>Some Demo<title>
</head>
<body></body>
</html>
HTML 5.0
HTML
Introduction to Website/Webpages Maintenance
HTML 5.0
Meta tags are created in the head section of a webpage. Most meta tags are created using a tag named meta.
The meta element uses (or must use) attributes that indicate what it is used for. The primary element used by
the meta tag is named name. This attribute is used to specify the meta tag that is being defined. The second
attribute is named content and it holds the value of the first attribute. The meta element is not closed.
Therefore, the primary formula to create a meta tag is:
<html>
<head>
<meta name="author" content=“Joy Nii Ofei Crisp-Dodoo">
<meta name="keywords" content=“mall, personal, business, shop, joyshopping">
<meta name="description" content="This is the corporate website of Watts A Loan, a small business that provides
loans and financial services.">
<title>Joy Shopping Mall</title>
<head>
HTML 5.0
If the value of an attribute is a number, simply assign that number to the attribute. If the
value of an attribute is a number or text:
If the value is in one word, you can just provide it. This would be done as follows:
attribute-name=value
You can put space in either or both sides of =, or you can omit the empty space.
Attributes are separated by empty spaces. Like tags, attributes follow some rules:
A paragraph is text that is physically separate from other text, such as another
paragraph. A paragraph is created with an element named p. Because a
paragraph is displayed to a visitor, it must be created by the body element.
<html>
<head>
<title>Anything Here</title>
</head>
<body>
<p>Now it is time to do some things.
</p>
</body>
</html>
HTML 5.0
<p>This section is for taxes paid or owed to the federal government. The Internal
Revenue Service (or IRS) collects such taxes.</p>
<h3>Social Security/Medicare</h3>
<h4>State Tax</h4>
HTML 5.0
The Title of an Attribute
The title of an element is a tool tip you want to display when the visitor's
mouse is positioned on top of the contents of the element. To create a tool tip
for an element, add an attribute named title. Specify the text of your choice
as the value of the attribute.
HTML 5.0
The Identification(ID)
All elements of a webpages are considered objects and each can be
programmatically accessed with code. The primary way to access an element
is by identifying it. To support this, an element can be given an attribute
named id (or ID). The value of the identifier must be a string in one word
starting with a letter.
HTML 5.0
<h2 id="mission" title="A sentence that defines why a company exists and
what its goals are.">Mission Statement</h2>
HTML 5.0
Text Alignment(Align)
When an element behaves as a container, you may want to position its content
to one side of its own container. To assist you with this, HTML provides an
attribute named align. It can take one three self-explanatory values that are:
left (the default), center, or right.
HTML 5.0
Horizontal Line(HR)
One way you can create a section on a webpage is to display a horizontal line.
This is done by creating an element using the hr tag.
HTML 5.0
<pre>===========================================
Department <span title="This section includes the budget allocated to each department">Revenues</span>
<span title="This section shows the budget fraction available for each department of the company">Margin</span>
===========================================
<span title="The administration includes employees payroll, community services, etc">Administration</span>
3.5<abbr title="Millions">M</abbr> 23.33%
-------------------------------------------
Loans/Services 9M 60.00%
-------------------------------------------
Marketing 1.12M 6.80%
-------------------------------------------
R and D 1.35M 7.33%
-------------------------------------------
<abbr title="Community Outreach">CO</abbr> 480<abbr title="K stands for kilos. It represents
thousands">K</abbr> 2.53%
===========================================</pre>
INTRODUCTION TO HTML TEXT ELEMENTS
A Smaller Text
If you want text to appear smaller than that default, apply an element named small. Here is
an example:
<p>Data mining is a technique used in data analysis to identify
patterns, <small>repeating occurrences</small>, in a series of records</p>
To create bold text, use either the b or the strong tag.
To underline text, apply the i element.
To underline text, apply the u element
To strike through text, apply the s or the strike element.
To display text higher on a line than the other characters of the same line, apply the sup
element. Here is an example:
<p>In geometry, if two sides of a right triangle are known, the other side can
HTML 5.0
You need to be precise and careful about positioning items such as text,
paragraphs, pictures, etc, on your webpages. Bad positioning can make your
webpage weird or unorganized. Fortunately, HTML (and especially CSS) provides
many tools to assist you.
HORIZONTAL RULE(HR)
<h1>F#: Object-Oriented Programming</h1>
<p>Here are examples of creating records:</p>
<hr>
<pre>type Employee = {
EmployeeNumber : string
FirstName : string
LastName : string
HourlySalary : float }<pre>
HTML 5.0
A Bold Text
To create bold text, use either the b or the strong tag.
Italicized Text
To italicize text, apply either the i or the em element.
Italicized Strike Text
A code element can be nested in a paragraph but a pre element should never be nested in a paragraph
Line breaks are built in the pre element. This means that the pre element is equipped to display text as it is created.
Line breaks are not built in the code element. If you want to have line breaks, you can add br elements.
<code>class Employee<br>
{<br>
string EmployeeNumber;<br>
string FirstName;<br>
string LastName;<br>
double HourlySalary;<br>
}</code>
HTML 5.0
ABBREVIATION(abbr)
An abbreviation is a technique of using a few letters or a combination of letters
and digits to represent a longer definition. To indicate that you want to show an
abbreviation, create an element named abbr. Normally, creating an abbr
element doesn't do anything. To indicate that a word represents an abbreviation,
you should add a title attribute to it and give the complete definition as the
value of that attribute.
A Blockquote
Published scholar papers usually contain citations to give credits to authors of
formal and interesting quotes. Some of the quotes are created in indented
paragraphs. To let you create such a paragraph, HTML provides a tag named
blockquote. Normally, a block quote behaves like a section; that is, it serves as a
contrainer. In its body, you can directly create text or nest other elements such
as paragraphs
. . . . . . .
<p align="center">Our financial statements include</p>
<blockquote>
<p>Administration 3.5M</p>
<p>Revenues</p>
<p>Margin 23.33%</p>
CO 480K
</blockquote></body></html>
HTML 5.0
The primary technique to initiate a link is to create an element named a. The primary attribute of
a link is named href. This attribute is used to indicate what to link. The formula to follow is:
<a href="">label</a>
A local link is a means of jumping from one section of a document to another section. This
functionality is available for vertical sections. One way to provide the ability to jump to a
section of a document is to add an identifier to an element. This is done by adding an id attribute
to an element.
To provide a local link in a document, provide the identifier of the element as the value of the
href attribute. The name of the identfier must be preceded with #.
Anchor Element
_self: This is the default value, applied if you don't use the target attribute.
With this value, the intended document displays in the same window as
the document that initiated the link
_parent: This most works as the _self value
A name: You must provide the name of the window or tab that will show
the targeted document.
_blank: When the visitor clicks the link, a new window or tab will be
created and display the intended document
_new: The first time the visitor clicks a link, a new window or tab will be
created and display the intended document. If the visitor clicks another
link that also has the _new value, the new document will replace the one
in the other window, but that other tab will stay in the background. If you
want to access that other document, you must click its window or tab
_top: When the user clicks the link, another window or tab may be
created to display the intended document and that window or tab will
display in front of the other windows or tab
Internal Links : Links can also be created inside large documents to
simplify navigation. Today’s world wants to be able to get the
information quickly. Internal links can help you meet these goals.
Select some text at a place in the document that you would like to
create a link to, then add an anchor to link to like this:
<A NAME=“bookmark_name”></A>
The Name attribute of an anchor element specifies a location in
the document that we link to shortly. All NAME attributes in a
document must be unique.
Next select the text that you would like to create as a link to the
location created above.
<A HREF=“#bookmark_name”>Go To Book Mark</A>
E-Mail (Electronic Mail)
E.g. mailto:[email protected]
The type of service is identified as the mail client program. This type
of link will launch the users mail client.
DL: Definition List. This kind of list is different from the others. Each item in a DL consists of one or more
Definition Terms (DT elements), followed by one or more Definition Description (DD elements).
<DL>
<DT> HTML </DT>
<DD> Hyper Text Markup Language </DD>
<DT> DOG </DT>
<DD> A human’s best friend!</DD>
</DL>
HTML
Hyper Text Markup Language
DOG
A human’s best friend!
HTML 5.0
Other means of creating sections
A section is created using a tag named section. Simply creating a section tab only
starts a new empty paragraph but it doesn't do anything significant. To make it
useful, you must add "content" to it. The section can contain paragraphs of text,
etc.
A webpage that displays to a visitor may be made of different parts. The top
section can be referred to as header. To create a section for such a part, create an
element named header. Such a section is made to hold an introduction to the
webpage.
A technique to create a section is by using a tag named aside. A section created as
this element is supposed to be related to the other contents of the same page.
The bottom part of a webpage can be referred to as footer. To specify a section for
such a part, create a section named footer. The section can be made to contain
such items as a copyright notice or a navigational menu.
HTML 5.0
An article
An HTML article is a section that can be accessed, used, and managed
independently from the rest of a web page. Examples of articles are: responses to
webpages at the ends of news articles, reactions posted in a forum, etc.
To create an HTML article, add a tag named article. When creating an article, it is
suggested that its first child be a heading (h1 to h5) that identifies what the article
is used for.
An address section
The address section is an area where you want to show the contact information. To
create such a section, use a tag named address.
HTML 5.0
A figure is a section you want to use in your webpage any way you see fit. To get
such a section, create an element named figure. You can then put anything you
want in that section.
Nav element
An HTML article is a section that can navigated independently from the rest of a
web page. Examples of articles are: responses to webpages at the ends of news
menus ,options,etc
Tables
In this chapter you will learn that tables have many uses in
HTML.
Objectives:
Upon completing this section, you should be able to:
1. Insert a table.
2. Explain a table’s attributes.
3. Edit a table.
4. Add a table header.
43
Tables
The <TABLE></TABLE> element has four sub-elements:
1. Table Row<TR></TR>.
2. Table Header <TH></TH>.
3. Table Data <TD></TD>.
4. Caption <CAPTION></CAPTION>.
The table row elements usually contain table header elements
or table data elements.
44
Tables
<table border=“1”>
<tr>
</tr>
<tr>
</tr>
<tr> 45
Tables
46
Tables Attributes
BGColor: Some browsers support background colors in a table.
Width: you can specify the table width as an absolute number of
pixels or a percentage of the document width. You can set the width
for the table cells as well.
Border: You can choose a numerical value for the border width,
which specifies the border in pixels.
CellSpacing: Cell Spacing represents the space between cells and is
specified in pixels.
47
Table Attributes
CellPadding: Cell Padding is the space between the cell border and the cell contents and is
specified in pixels.
Align: tables can have left, right, or center alignment.
Background: Background Image, will be titled in IE3.0 and above.
BorderColor, BorderColorDark.
48
Table Caption
A table caption allows you to specify a line of text
that will appear centered above or bellow the table.
<TABLE BORDER=1 CELLPADDING=2>
<CAPTION ALIGN=“BOTTOM”> Label For My Table
</CAPTION>
The Caption element has one attribute ALIGN that
can be either TOP (Above the table) or BOTTOM
(below the table).
49
Table Header
Table Data cells are represented by the TD
element. Cells can also be TH (Table Header)
elements which results in the contents of the
table header cells appearing centered and in bold
text.
50
Table Data and Table Header Attributes
Colspan: Specifies how many cell columns of the table this
cell should span.
Rowspan: Specifies how many cell rows of the table this cell
should span.
Align: cell data can have left, right, or center alignment.
Valign: cell data can have top, middle, or bottom alignment.
Width: you can specify the width as an absolute number of
pixels or a percentage of the document width.
Height: You can specify the height as an absolute number of
pixels or a percentage of the document height.
51
Basic Table Code
<TR><TD>3480-AB</TD><TD>80mm Socket</TD><TD>50.00</TD></TR>
</TABLE>
52
Table Data and Table Header Attributes
<Table border=1 cellpadding =2>
<tr> <th> Column 1 Header</th> <th> Column 2
Header</th> </tr>
<tr> <td colspan=2> Row 1 Col 1</td> </tr>
<tr> <td rowspan=2>Row 2 Col 1</td>
<td> Row 2 Col2</td> </tr>
<tr> <td> Row 3 Col2</td> </tr>
</table>
53
Table Data and Table Header Attributes
Row 1 Col 1
Row 2 Col 2
Row 2 Col 1
Row 3 Col 2
54
Special Things to Note
•
TH, TD and TR should always have end tags.
Although the end tags are formally optional, many browsers will
mess up the formatting of the table if you omit the end tags. In
particular, you should always use end tags if you have a TABLE
within a TABLE -- in this situation, the table parser gets hopelessly
confused if you don't close your TH, TD and TR elements.
•
A default TABLE has no borders
By default, tables are drawn without border lines. You need the
BORDER attribute to draw the lines.
•
By default, a table is flush with the left margin
TABLEs are plopped over on the left margin. If you want centered
tables, You can either: place the table inside a DIV element with
attribute ALIGN="center".
Most current browsers also supports table alignment, using the
ALIGN attribute. Allowed values are "left", "right", or "center", for
example: <TABLE ALIGN="left">. The values "left" and "right" float
the table to the left or right of the page, with text flow allowed
around the table. This is entirely equivalent to IMG alignment
55
What will be the output?
56
The Output
57
HTML 5.0
One of the styles you can apply to text is to specify its size. This is done using a style
named font-size. The value of this style can be:
1)An absolute value: xx-small, x-small, small, medium, large, x-large, or xx-large
2)A relative value depending on the immediate element in which it is nested. The values
can be: smaller or larger
3)A decimal value
4)A percentage
HTML 5.0
TEXT COLOR
By default, text displays in black. To let you specify the color of text, CSS has a style named
color. The value of this style is the name of any color you know. All popular names of colors
are valid. Examples are Red, Black, White, Blue, Green, Yellow, Brown, Navy, Orange,
Maroon, Tan, Silver, Olive, Purple, Teal, Violet, Wheat, Aqua (or Cyan), Magenta (or Fuchsia),
Lime, Pink, Gold, Khaki, Tomato, Ivory, Salmon, Turquoise, Lavender, Indigo, Plum,
Chocolate, Beige, Orchid, Honeydew, Peru, and Snow, DarkRed, LightBlue, RoyalBlue,
SkyBlue, LightSkyBlue, LightSteelBlue, MediumBlue, MidnightBlue, LightGreen,
ForestGreen, LimeGreen, SeaGreen, SpringGreen, DarkGreen, LawnGreen, MediumSeaGreen,
PaleGreen, GreenYellow, YellowGreen, LightYellow, FloralWhite, OrangeRed, LightCyan,
MediumPurple, HotPink, DarkMagenta, FireBrick, DimGray, IndianRed, DarkOrange,
DarkViolet, DarkTurquoise, DarkOliveGreen, DarkKhaki, DeepSkyBlue, LightPink, DeepPink,
MediumTurquoise, and WhiteSmoke.
The names of colors are not case-sensitive. This means that you can use a ll lowercase: Examples
are red, green, or white
All uppercase: Examples are RED, YELLOW, or MAGENTA
HTML 5.0
MANY STYLES
You can apply as many styles as you need to an element. You have many options. When
inline, you can create different styles in the style attribute. In this case, each style must
end with a semi-colon. You can omit or use a semicolon on the last style
<h4 style="font-family: Georgia; font-size: 14pt; color: red;">Database Management:
Security</h4>
On an HTML element, the style attribute is used to apply a style to only that element. if you want to apply the
same style to another tag, you must re-create the same style on that other tag. The alternative is to create the
style at file scope and make the style available to any HTML element in the same file.
To create a style that can be applied to various HTML tags of a document, in the head
section of the webpage, create an element named style and close.
<style type="text/css">
</style>
HTML 5.0
CSS-CASCADING STYLE SHEET
CREATING A CSS FILE
If you create a style directly in an HTML document that uses it, the style is available only
in that webpage. In some cases, you may want to apply a style to elements in different
webpages. To do that, you can create CSS code in its own file and let other pages access it..
A file-based CSS is created as a normal text-based document. The content of the file is made of styles like those
created in the head section of a webpage. The only different is that code in the CSS file doesn't have to be
delimited with <style> and </style>. A CSS file has the extension .css
You can create a file-based style in a folder of your website. Here is the content of a file named exercise.css:
JAVA SCRIPT
JAVA SCRIPT
JAVA SCRIPT
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
</script>
</head>
<body>
</body>
</html>