Essential HTML Tags
Essential HTML Tags
Objective:
þ Apply appropriate HTML tags, anchor and img elements, inline styles, borders,
and forms.
Key Terms:
Ñ alt attribute
anchor element
font-weight property
form element
src attribute
style attribute
attribute header tag SVG
background property href attribute tag
body tag HTML tag target
border property img tag text-align property
color property inline style text-decoration property
CSS letter-spacing property text-indent property
element line-height property text-transformation
essential HTML tags link property
font-family property margins property title tag
font property padding property word-spacing property
font-size property rgb function
font-style property span
HTML Tag
The HTML tag is a structure that defines the document as a webpage and identifies the
beginning and the end of the HTML document. All other tags are arranged between the start
and end HTML tags.
Header Tag
The header tag is a structure that contains the document information provided to search
engines and browsers. It is information not viewable on the actual webpage: document title,
author, keywords, style sheet type used, and any meta-tags. The header information is embed-
ded in the HTML tags.
<HEAD> </HEAD>
Title Tag
The title tag is a structure that defines the name/label that appears in the title bar of the
web browser (and in search engine results). A title tag does not appear on the webpage. It must
be embedded between the HEAD tags.
<TITLE> </TITLE>
Body Tag
The body tag is a structure that includes all the visible content of the document and other
visible content, including images, links, and plain text. All content must be embedded between
the start and end BODY tags.
<BODY> </BODY>
Element
An element is an object on a page: a heading, paragraph, and/or an image.
Attribute
HTML elements may contain attributes. In HTML, an attribute is additional information
or a quality (or qualities) that describe an element: width, height, etc. Working with attributes
is important because some HTML elements cannot work properly until the correct attributes
are set. Specifically, note the following:
t An attribute may not exist by itself. It must be part of an element, and it is always speci-
fied in the start tag of the element. [NOTE: In HTML syntax, an attribute is added to an
HTML start tag.]
t End tags are not populated HTML Element Attribute
with attributes. <h1 id = "blueHeading"> id="blueHeading"
t A single element may have <p title = "subject_matter"> title = "subject_matter"
multiple attributes. <h3 align='left'> align='left'
t Attributes are separated FIGURE 1. Attribute values must be surrounded by matched double quotes or
from one another by one or single quotes. Attribute names cannot be changed. The value placed in an
attribute depends upon the application requirements.
more spaces.
ANCHOR ELEMENT
HTML files may contain links to other files or to a web URL. A key feature of the web is
the ability to link (connect or hyperlink) resources: other webpages, locations in the current
document, media files (e.g., images and video), and programs. By default, links appear in blue
underlined text. When a link is clicked, the browser navigates to another HTML page. The
anchor element is the link source and destination. An anchor is coded in HTML using the
<a> element. This tag has a start and an end tag.
href Attribute
The href attribute can point to an HTML file instead of a web URL. For example, the href
tag can be specified as <a href = "myexample1.html">. If no path notation is provided in the
href attribute, the HTML file specified in the href attribute must be in the same folder as the
calling HTML file. If the target HTML file is not in the same folder as the HTML file, relative
path notation must be used.
Target
The anchor element can contain an optional attribute called “target.” Target is an attribute
that specifies the location of the target URL. The default value is “_self”. This loads the URL
in the same browser window as the one calling it. When target is set to “_blank”, the target
URL is loaded in a new window or tab.
them in the same manner as FIGURE 5. This is an img element using an svg file in its src attribute. The image
image files. See FIGURE 5. drawn by the svg file is large. To scale it, img element’s width and height attributes
are set.
Color-Related Properties
CSS allows you to set the color for the text in an element, place a colored border around an
element, and set the background color for an element. CSS supports by name all the colors
supported by HTML. The 16 standard colors supported by CSS are aqua, black, blue, fuchsia,
gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. A list of col-
Font-Related Properties
CSS contains various font-related properties. The four main font-related properties are font
family, font style, font weight, and font size. In most Windows applications, a specific font may
be applied to selected text. However, in web applications, fonts are not specified by name.
Instead, they are specified by families because it is hard to predict whether a specific font is
present on a client computer. In CSS, the font-family property is a format that specifies the
font for an element. When setting up font-family, generic font families or specific fonts may be
used.
Generic families are:
Font-Weight Property
The font-weight property is a structure used to change the thickness of the rendered
font. It can hold the value normal, bold, bolder, or lighter in addition to a number that is a
multiple of 100 in the range 100 to 900. The property values “lighter” and “bolder” are relative
to the current property value. The property value “normal” corresponds to a numeric value of
400, while bold has a value of 700. Whether other numeric weights are supported depends
upon the font.
Not all fonts support all weights. For example, the Times New Roman font only supports
bold and normal weights. Even when using a font family that supports multiple weights, there
is not much difference between the renderings of text in a browser. It is best to use only nor-
mal and bold as property values for the font-weight property.
t The named terms are small, medium, large, X-large, and XX-large.
t The relative terms are larger or smaller.
t When font size is specified using numeric values, it is usually specified using “px” (pixel)
as the unit of measure. Size can also be specified as a percentage. When a percentage is
specified, it is relative to the font size of the parent element.
Font Property
The font property is a structure that CSS allows for setting of all font-related properties.
The font property value should be specified in this order: font-style font-weight font-size/line-
height font-family. When the font property is used, font-size and font-family are required. If
other values are not specified, default values are used.
Text-Related Properties
Text-related properties allow for the formatting of text characteristics. These properties are
word spacing, letter spacing, text decoration, text transformation, text alignment, text indenta-
tion, and line height.
Word-Spacing Property
The word-spacing property is a format that specifies the amount of white space between
words. The default value is 0.25em, which is 25 percent of the space taken up by the latter “m.”
This default value can be changed. The change may be specified in px, cm, or em.
Letter-Spacing Property
The letter-spacing property is a format that specifies the space between letters in a
word. By default, no extra space is left between characters in a word. It may be specified as
normal or in units of px, cm, or em.
Text-Decoration Property
The text-decoration property is a format that can be set to none, underline, over-line,
or line-through.
Text-Transformation Property
The text-transformation property is a format that alters text in one of four ways.
Text-Align Property
The text-align property is a format used to arrange text in an element. Possible values
are left, right, center, and justify.
Text-Indent Property
The text-indent property is a format that defines the amount of distance or space
(indentation) before the first line of the text in an element. The value is specified as a length or
as a percentage and refers to the default width of the element.
Line-Height Property
The line-height property is a format that determines the space between lines of text
when it is displayed in the browser. It is specified as a percentage or as a number with the units
used in CSS for length, such as px or em.
FURTHER EXPLORATION…
ONLINE CONNECTION: Web Server Programs
The World Wide Web can be visualized
as a vast network of web servers and client
machines connected by communication
protocols. Designing and developing HTML
files is only part of the picture. It is essen-
tial to understand the inner workings of
web servers that host HTML files.
Various types of web server programs
exist. The type of web server program run-
ning on the web server needs to be taken
into consideration when developing a
website. It is also important to learn the
web server environment when creating This is a network engineer in a datacenter server room.
HTML forms to collect user information to
send to a program on a web server.
To find out more about web server software, visit the “Web-Server Types” link at:
http://www.tutorialspoint.com/web_developers_guide/web_server_types.htm
Layout Properties
Element layout properties are specified when padding and margin properties are set. These
two properties can use “in” for inches, “cm” for centimeters, “mm” for millimeters, “px” for
pixels, and “pt” for points.
Margins Property
The margins property is a format that specifies the space to be left between elements,
outside of the element border.
Padding Property
The padding property is a format that leaves space around an element. The size of pad-
ding is specified as a percentage of the size of the parent element or in absolute terms with
units of measure. When padding is specified, it places spaces between the element and its bor-
der.
Inline Display
Inline are those elements that do not span a • <div>
Block-level • <h1> - <h6>
line. For example, the inline element span can elements
be used to apply formatting for a small section • <p>
of text within a paragraph. The span is an ele-
ment with a start and an end tag. FIGURE 10. These are block and inline element categories.
t The div element is a special block-level element. It is always specified with the start and
the end tag. While a div tag may be used to hold text, it is common practice to use a div
tag as a container to hold other elements. The nested elements are referred to as the child
elements of the div element.
t A div start tag may contain style parameters. When style properties are set for the div ele-
ment, it is applied to all elements placed inside the div element. The third div element
contains two child elements inside it: an h3 element and a paragraph element. The style
specifications in the parent div element flow down to the child elements.
CSS Hierarchy
CSS styles can be specified for a div element and for the children element inside the div ele-
ment. If this is encountered, the CSS specification closest to the element takes effect. Specifi-
cations for the paragraph element take precedence over specifications for the parent div
element.
https://www.elegantthemes.com/blog/editorial/the-current-state-of-the-internet-browser-wars
Form Element
The form element is a two-sided element to collect data and is always coded with a start
and an end tag. Data collected in a form is sent to a single web server program. A single HTML
file may contain multiple forms, with data from each form sent to a different server program.
The form start tag requires you to specify two attributes: method attribute and action attrib-
ute. The method attribute describes how user data is transferred to the server. It may have the
value “get” or “post.” The action specifies the name of the program on the server that receives
form data. See FIGURE 11.
HTML Code
<!DOCTYPE html>
<html>
<head>
<title>Trying out HTML</title>
</head>
<body>
<form method="post" action="http://www.mysite.com/checkForm.php">
.
.
.
</form>
</body>
</html>
FIGURE 11. The HTML code contains one logical form, represented within the <form> and </
form> tags. The POST method is used to send the user data collected by this form back to
the server. The data will be sent a program called checkForm.php on http://www.mysite.com.
get vs. post—Two values exist for the method attribute of the form element: “get” and
“post.” When “get” is used, the information from the form is appended to the URL of the web
server program that receives the form data. When “post” is used, form data is sent via the
HTTP request. It is not appended to the URL.
Summary:
2 Essential HTML tags are the basic structures required for every HTML file that
controls the overall structure of the webpage. The HTML tag is a structure that
defines the document as a webpage and identifies the beginning and the end of the
HTML document. The header tag is a structure that contains the document infor-
mation provided to search engines and browsers. In contrast, the title tag is a struc-
ture that defines the name/label that appears in the title bar of the web browser (and
in search engine results). The body tag is a structure that includes all the visible
content of the document and other visible content, including images, links, and
plain text. An element is an object on a page (e.g., a heading, paragraph, and/or an
image).
L Code an HTML table with names and pictures of your family and friends. Create a
different color for family and a different color for friends.
Web Links:
CSSDesk
http://www.cssdesk.com/
HTML Attributes
http://www.w3schools.com/html/html_attributes.asp