HTML Basics for Web Designers
HTML Basics for Web Designers
Now, HTML is being widely used to format web pages with the help of
different tags available in HTML language.
DEFINITION
In HTML you describe the content in pure text, by defining text as
headings, paragraphs, lists, etc. A tag is a text surrounded by angle
brackets.
Tags usually have a beginning and end and contain other text between
the start and end tag. The normal content of the webpage is placed
between the <body> </body> tags, the <head> </head> tag contains
general information about the webpage
HISTORY
1989 Tim Berners-Lee invented www
1991 Tim Berners-Lee invented HTML
1993 Dave Ragget drafted HTML+
1995 HTML working group defined HTML 2.0
1997 W3C recommendation: HTML 3.2
1999 W3C recommendation: HTML 4.01
2000 W3C recommendation: XHTML 1.0
2012 WHATWG HTML5 living standard
2016 W3C candidate recommendation: HTML 5.1
HTML TAGS
As told earlier, HTML is a markup language and makes use of various
tags to format the content. These tags are enclosed within angle
braces <Tag Name>. Except few tags, most of the tags have their
corresponding closing tags. For example <html> has its closing tag
</html> and <body> tag has its closing tag </body> tag etc.
TAG DESCRIPTION
<!DOCTYPE... This tag defines the document type and HTML version.
<html> This tag encloses the complete HTML document and mainly
comprises of document header which is represented by
<head>...</head> and document body which is represented
by <body>...</body> tags.
<head> This tag represents the document's header which can keep
other HTML tags like <title>, <link> etc.
<h1> and <p> This tag represents the heading and paragraph respectively
To learn HTML, you will need to study various tags and understand
how do they behave while formatting a textual document. Learning
HTML is simple as users have to learn the usage of different tags in
order to format the text or images to make a beautiful webpage.
<html>
<head>
<meta charset=“UTF-8”>
<title> Title of the document</title>
</head>
<body>
</body>
</html>
THE <!DOCTYPE>
DECLARATION
The <!DOCTYPE> declaration tag is used by the web browser to
understand the version of the HTML used in the document. Current
version of HTML is 5 and it makes use of the following declaration:
HEADING TAGS
Any document starts with a heading. You can use different
sizes for your headings. HTML also has six levels of headings,
which use the elements <h1>, <h2>, <h3>, <h4>, <h5>,
and <h6>.
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
LINE BREAK TAG
Whenever you use the <br /> element, anything following it starts
from the next line. This tag is an example of an empty element,
where you do not need opening and closing tags, as there is nothing
to go in between them.
The <br /> tag has a space between the characters br and the
forward slash. If you omit this space, older browsers will have trouble
rendering the line break, while if you miss the forward slash
character and just use <br> it is not valid in XHTML
EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>Linebreak Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment
ontime.<br />
Thanks<br />
Mahnaz
</p>
</body>
</html>
CENTERING CONTENT
You can use <center> tag to put any content in the center of the
page or any table cell.
<!DOCTYPE html>
<html>
<head>
<title>Center Example</title>
</head>
<body>
<center>
<p> This text is centered </p>
</center>
</body>
</html>
HORIZONTAL LINES
Horizontal lines are used to visually break up sections of a
document. The <hr> tag creates a line from the current position in
the document to the right margin and breaks the line accordingly.
<!DOCTYPE html>
<html>
<head> <title>Horizontal Line Example</title>
</head>
<body>
<p> This line is on top</p>
<hr/>
<p> This line is on top</p>
</body>
</html>
HTML ELEMENTS
An HTML element is defined by a starting tag. If the element
contains other content, it ends with a closing tag, where the element
name is preceded by a forward slash
For example <p> is starting tag of a paragraph and </p> is closing tag
of the same paragraph but <p>This is paragraph</p> is a paragraph
element.
HTML TAGS
HTML Phrase Tag
Phrase Tag: In HTML, phrase tag is used to indicate
the structural meaning of a block of text. For example,
abbr tag indicates that the phrase contained the
abbreviation word. Some examples of phrase tags are
<abbr>, <strong>, <mark>, . . . etc.
Emphasized Text: The <em> tag is used to
emphasized the text and this tag displays the italic
font in a browser. It simply means anything written
within em tag is shown as emphasized Text.
Syntax:
HTML TAGS
NESTED HTML ELEMENTS
It is very much allowed to keep one HTML element inside another HTML element:
<!DOCTYPE html>
<html>
<head>
<title>nested elements</title>
</head>
<body>
<h1> This text is <i>italic</i></h1>
<p> This text is <u>underlined</u></p>
</body>
</html>
HTML ATTRIBUTES
An attribute is used to define the characteristics of an HTML element
and is placed inside the element's opening tag.
All attributes are made up of two parts: a name and a value:
• The name is the property you want to set. For example, the paragraph
<p> element in the example carries an attribute whose name is align,
which you can use to indicate the alignment of paragraph on the
page.
• The value is what you want the value of the property to be set and
always put within quotations. The below example shows three
possible values of align attribute: left, center and right.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>Line Break Example</title>
</head>
<body>
<p align=“left”> This is aligned left</P>
<p align=“center”> This is aligned center</P>
<p align=“right”> This is aligned right</P>
</body>
</html>
SOME GENERIC ATTRIBUTES
Attributes Options Functions
Places a background
background URL
image behind an element
FORMATING
Bold Text
Anything that appears within <b>...</b> element, is displayed in bold
Italic Text
Anything that appears within <i>...</i> element is displayed in italicized
Underlined Text
Anything that appears within <u>...</u> element, is displayed with underline
Strike Text
Anything that appears within <strike>...</strike> element is displayed with
strikethrough, which is a thin line through the text
Superscript Text
The content of a <sup>...</sup> element is written in superscript; the font size
used is the same size as the characters surrounding it but is displayed half a
character's height above the other characters.
FORMATING
Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is
the same as the characters surrounding it, but is displayed half a character's height
beneath the other characters.
Inserted Text
Anything that appears within <ins>...</ins> element is displayed as inserted text.
Deleted Text
Anything that appears within <del>...</del> element, is displayed as deleted text.
Larger Text
The content of the <big>...</big> element is displayed one font size larger than the rest
of the text surrounding it
Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than
the rest of the text surrounding it
FORMATING
Text Abbreviation: To abbreviate a text in HTML
use abbr tag. Abbreviation of text written within
opening and closing abbr tag.
Syntax:
<h1>MYJOY</h1>
<!-- abbr tag is used in below paragraph-->
</body>
</html>
FORMATING
Marked Text: The content written within the
open and close mark tag will display as a
yellow mark. Basically, it works like a
highlighter and it is used to highlight some
words in a sentence.
Syntax:
<mark> Text Content </mark>
FORMATING
<html>
<body>
<h1>MYJOYONLINE</h1>
</body>
</html>
HTML BACKGROUNDS
By default, your webpage background is white in color. You may not like it, but no
worries. HTML provides you following two good ways to decorate your webpage
background.
• Html Background with Colors
• Html Background with Images
Attribute Description
This specifies the width of the marquee. This can be a value like 10 or
width 20% etc.
This specifies the height of the marquee. This can be a value like
height 10 or 20% etc.
This specifies the direction in which marquee should scroll. This
direction can be a value like up, down, left or right.
This specifies the type of scrolling of the marquee. This can
behavior have a value like scroll, slide and alternate.
This specifies how long to delay between each jump. This will
scrolldelay have a value like 10 etc.
MARQUEE ATTRIBUTES
Following is the list of important attributes which can be used with <marquee> tag.
Attribute Description
This specifies the speed of marquee text. This can have a value like 10
scrollamount etc.
This specifies how many times to loop. The default value is
loop INFINITE, which means that the marquee loops endlessly.
The font tag is having three attributes called size, color, and
face to customize your fonts. To change any of the font
attributes at any time within your webpage, simply use the
<font> tag. The text that follows will remain changed until you
close with the </font> tag. You can change one or all of the
font attributes within one <font> tag.
HTML FONTS
Note: The font and basefont tags are deprecated and it is
supposed to be removed in a future version of HTML. So they
should not be used rather, it's suggested to use CSS styles to
manipulate your fonts. But still for learning purpose, this
chapter will explain font and basefont tags in detail.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>Setting Font Size</title>
</head>
<body>
<font size="1">Font size="1“</font><br />
<font size="2">Font size="2“</font><br />
<font size="3">Font size="3"</font><br />
<font size="4">Font size="4"</font><br />
<font size="5">Font size="5"</font><br />
<font size="6">Font size="6"</font><br />
<font size="7">Font size="7"</font>
</body>
</html>
RELATIVE FONT SIZE
You can specify how many sizes larger or how many sizes smaller
than the preset font size should be. You can specify it like
<font size="+n"> or <font size="-n">
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>Setting Font Size</title>
</head>
<body>
<font size="-1">Font size="-1"</font><br />
<font size="+1">Font size="+1"</font><br />
<font size="+2">Font size="+2"</font><br />
<font size="+3">Font size="+3"</font><br />
<font size="+4">Font size="+4"</font>
</body>
</html>
SETTING FONT FACE
You can set font face using face attribute but be aware that if
the user viewing the page doesn't have the font installed, they
will not be able to see it. Instead user will see the default font
face applicable to the user's computer.
A visitor will only be able to see your font if they have that font installed on
their computer. So, it is possible to specify two or more font face alternatives
by listing the font face names, separated by a comma.
<font face="arial,helvetica"> <font face="Lucida Calligraphy,Comic
Sans MS,Lucida Console">
When your page is loaded, their browser will display the first font face
available. If none of the given fonts are installed, then it will display the
default font face Times New Roman.
The <basefont> tag also takes color, size and face attributes and it will
support relative font setting by giving size a value of +1 for a size larger or -
2 for two sizes smaller.
EXAMPLE FONT FACE
<!DOCTYPE html>
<html>
<head> <title>Setting Font Size</title>
</head>
<body>
<font face="Times New Roman" size="5">Times New
Roman</font><br /> <font face="Verdana"
size="5">Verdana</font><br />
<font face="Comic sans MS" size="5">Comic Sans MS</font><br />
<font face="WildWest" size="5">WildWest</font><br />
<font face="Bedrock" size="5">Bedrock</font><br />
</body>
</html>
EXAMPLE FONT COLOR
<!DOCTYPE html>
<html>
<head> <title>Setting Font Size</title>
</head>
<body>
<font color="#FF00FF">This text is in pink</font><br />
<font color="red">This text is red</font>
</body>
</html>
EXAMPLE BASE FONT
<!DOCTYPE html>
<html>
<head> <title>Setting Font Size</title>
</head>
<body>
<basefont face="arial, verdana, sans-serif" size="2"
color="#ff0000"> <p>This is the page's default font.</p>
<h2>Example of the <basefont> Element</h2>
<p><font size="+2" color="darkgray"> This is darkgray text with
two sizes larger </font></p>
<p><font face="courier" size="-1" color="#000000"> It is a courier
font, a size smaller and black in color. </font></p>
</body>
</html>
HTML TABLES
The HTML tables allow web authors to arrange data like text,
images, links, other tables, etc. into rows and columns of cells.
The HTML tables are created using the <table> tag in which
the <tr> tag is used to create table rows and <td> tag is used
to create data cells.
EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>tables example</title>
</head>
<body>
<table border=“1”>
<tr>
<td>row1column1</td>
<td>row1column2</td>
</tr>
<tr>
<td>row2column1</td>
<td>row2column2</td>
</tr>
</body>
</html>
TABLE HEADING
Table heading can be defined using <th> tag. This tag will be
put to replace <td> tag, which is used to represent actual data
cell. Normally you will put your top row as table heading as
shown below, otherwise you can use <th> element in any row.
<tr>
<td>Kofi Kumi</td>
<td>Ghc 1000</td>
</tr>
<tr>
<td>Adwoa Kwaata</td>
<td>Ghc 1000</td>
</tr>
</table>
</body>
EXAMPLE(cellpading/
cellspacing)
<!DOCTYPE html>
<html>
<head>
<title>tables example</title>
</head>
<body>
<table border=“1” cellpading=“5” cellspacing=“5” >
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Kofi Kumi</td>
<td>Ghc 1000</td>
</tr>
<tr>
<td>Adwoa Kwaata</td>
<td>Ghc 1000</td>
</tr>
</body>
COLSPAN AND ROWSPAN
ATTRIBUTES
You will use colspan attribute if you want to merge two or
more columns into a single column. Similar way you will use
rowspan if you want to merge two or more rows.
EXAMPLE(colspan and rowspan)
<!DOCTYPE html>
<html>
<head>
<title>tables example</title>
</head>
<body>
<table border=“1” cellpading=“5” cellspacing=“5” >
<tr>
<th>column 1</th>
<th>column 2</th>
<th>column 3</th>
</tr>
<tr>
<td rowspan="2">Row 1 Cell 1</td><td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</body>
</html>
TABLES BACKGROUND
You can set table background using one of the following two
ways:
BGCOLOR ATTRIBUTE - You can set background color for whole table
or just for one cell.
BACKGROUND ATTRIBUTE - You can set background image for whole
table or just for one cell.
You can also set border color also using BORDERCOLOR ATTRIBUTE.
TABLES HEIGHT AND WIDTH
You can set a table width and height using width and height attrubutes.
You can specify table width or height in terms of pixels or in terms of
percentage of available screen area.
EXAMPLE
<table height=“400” width=“150”>
TABLE
CAPTION
The caption tag will serve as a title or explanation for the table and it
shows up at the top of the table. This tag is deprecated in newer version
of HTML/XHTML.
<caption>This is caption</caption>
TABLE HEADER, BODY, AND
FOOTER
Tables can be divided into three portions: a header, a body, and a foot. The head
and foot are rather similar to headers and footers in a word-processed document
that remain the same for every page, while the body is the main content holder of
the table.
The three elements for separating the head, body, and foot of a table are:
<THEAD> - to create a separate table header.
<TBODY> - to indicate the main body of the table.
<TFOOT> - to create a separate table footer.
A table may contain several <tbody> elements to indicate different pages or
groups of data. But it is notable that <thead> and <tfoot> tags should
appear before <tbody>
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>HTML Table</title>
</head>
<body>
<table border="1" width="100%">
<thead>
<tr> <td colspan="4">This is the head of the table</td> </tr> </thead>
<tfoot>
<tr> <td colspan="4">This is the foot of the table</td> </tr> </tfoot>
<tbody>
<tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td>
</tr>
</tbody>
</table>
</body>
</html>
LINKS
A webpage can contain various links that take you directly to other
pages and even specific parts of a given page. These links are known
as hyperlinks.
A link is specified using HTML tag <a>. This tag is called anchor
tag and anything between the opening <a> tag and the closing </a>
tag becomes part of the link and a user can click that part to reach to
the linked document. Following is the simple syntax to use <a> tag.
<a href="Document URL" ... attributes-list>Link Text</a>
LINKING DOCUMENTS
A link is specified using HTML tag <a>. This tag is
called anchor tag and anything between the opening <a> tag
and the closing </a> tag becomes part of the link and a user
can click that part to reach to the linked document. Following
is the simple syntax to use <a> tag.
<a href="Document URL" ... attributes-list>Link
Text</a>
EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href="[Link] target="_self">Tutorials
Point</a>
</body>
</html>
THE TARGET ATTRIBUTE
We have used target attribute in our previous example. This
attribute is used to specify the location where linked document
is opened. Following
Option are possible options:
Description
_blank Opens the linked document in a new window or tab.
_self Opens the linked document in the same frame.
_parent Opens the linked document in the parent frame.
_top Opens the linked document in the full body of the
window.
targetframe Opens the linked document in a named
targetframe.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>Hyperlink Example</title>
<base href="[Link]
</head>
<body>
<p>Click any of the following links</p>
<a href="/[Link]" target="_blank">Opens in New</a> |
<a href="/[Link]" target="_self">Opens in Self</a> |
<a href="/[Link]" target="_parent">Opens in Parent</a> |
<a href="/[Link]" target="_top">Opens in Body</a>
</body>
</html>
USE OF BASE PATH
When you link HTML documents related to the same website, it
is not required to give a complete URL for every link. You can
get rid of it if you use <base> tag in your HTML document
header. This tag is used to give a base path for all the links. So
your browser will concatenate given relative path to this base
path and will make a complete URL.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>Hyperlink Example</title>
<base href="[Link]
</head>
<body>
<p>Click following link</p>
<a href="/[Link]" target="_blank">HTML Tutorial</a>
</body>
</html>
NAV,ASIDE,ARTICLE,FOOTER,ADDRE
SS
HTML5 introduced several new ways of classifying content of the
webpage, e.g., <nav> </nav> for the navigation part of the page,
<article> to represent an independent article,<aside> </aside> to
represent a sidebar with related information.<footer> </footer> for
a footer in the HTML page and <address> </address> for the
contact information of the author.
HTML <img> /<picture> Tag
Syntax
The basic syntax of the <picture> tag is given with:
<picture>
<img src="URL" alt="text">
</picture>
The example below shows the <picture> tag in action.
You can also include a <noembed> tag for the browsers which
don't recognize the <embed> tag. You could, for example, use
<embed> to display a movie of your choice, and <noembed>
to display a single JPG image if browser does not support
<embed> tag.
EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>HTML embed Tag</title>
</head>
<body>
<embed src="/html/[Link]" width="100%" height="60" >
<noembed><img src="[Link]" alt="Alternative Media" >
</noembed>
</embed>
</body>
</html>
THE <EMBED> TAG
ATTRIBUTES
Following is the list of important attributes which can be used
with <embed> tag.
Attribute Description
align Determines how to align the object. It can be set to
either center, left or right.
autostart This boolean attribute indicates if the media should start
automatically. You can set it either true or false.
loop Specifies if the sound should be played continuously (set
loop to true), a certain number of times (a positive value)
or not at all (false)
playcount Specifies the number of times to play the sound. This is
alternate option for loop if you are usiong IE.
hidden Specifies if the multimedia object should be shown on
the page. A false value means no and true values means
yes.
width Width of the object in pixels
height Height of the object in pixels
name A name used to reference the object.
src URL of the object to be embedded.
volume Controls volume of the sound. Can be from 0 (off) to 100
(full volume).
SUPPORTED VIDEO TYPES
You can use various media types like Flash movies (.swf), AVI's
(.avi), and MOV's (.mov) file types inside embed tag.
.mpeg files - are movie files created by the Moving Pictures Expert
Group.
BACKGROUND AUDIO
You can use HTML <bgsound> tag to play a soundtrack in the
background of your webpage.
This tag is supported by Internet Explorer only and most of the
other browsers ignore this tag. It downloads and plays an audio
file when the host document is first downloaded by the user and
displayed. The background sound file also will replay whenever
the user refreshes the browser.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>HTML embed Tag</title>
</head>
<body>
<bgsound src="/html/[Link]">
<noembed><img src="[Link]" >
</noembed>
</bgsound>
</body>
</html>
Attribute Description
autoplay
This Boolean attribute if specified, the video will automatically begin to play back as soon
as it can do so without stopping to finish loading the data.
autobuffer
This Boolean attribute if specified, the video will automatically begin buffering even if it's
not set to automatically play.
loop Specifies if the sound should be played continuously (set loop
to true), a certain number of times (a positive value) or not at all (false)
poster
This is a URL of an image to show until the user plays or seeks.
width Width of the object in pixels
height Height of the object in pixels
preload
This attribute specifies that the video will be loaded at page load, and ready to run.
Ignored if autoplay is present.
Src: The URL of the video to embed. This is optional; you may instead use the <source>
element within the video block to specify the video to embed.
Controls:
If this attribute is present, it will allow the user to control video playback, including volume,
seeking, and pause/resume playback.
HTML FORMS
HTML Forms are required when you want to collect some data from the site
visitor. For example during user registration you would like to collect
information such as name, email address, credit card, etc.
A form will take input from the site visitor and then will post it to a back-end
application such as CGI, ASP Script or PHP script etc. The back-end application
will perform required processing on the passed data based on defined business
logic inside the application.
There are various form elements available like text fields, textarea fields, drop-
down menus, radio buttons, checkboxes, etc.
The HTML <form> tag is used to create an HTML form and it has following
syntax:
Attribute Description
method Method to be used to upload data. The most frequently used are
GET and POST methods.
target Specify the target window or frame where the result of the script
will be displayed. It takes values like _blank, _self, _parent etc.
You can use the enctype attribute to specify how the browser encodes the
data before it sends it to the server. Possible values are:
Note: You can refer to Perl & CGI for a detail on how form data upload works.
HTML FORM CONTROLS
There are different types of form controls that you can use to collect data using
HTML form:
• Text Input
Controls
• Checkboxes
Controls
• Radio Box
Controls
• Select Box
Controls
• File Select boxes
• Hidden Controls
• Clickable Buttons
• Submit and Reset
Button
TEXT INPUT CONTROLS
There are three types of text input used on forms:
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>HTML embed Tag</title>
</head>
<body>
<form >
First name: <input type="text" name="first_name" /> <br>
Last name: <input type="text" name="last_name" />
</form>
</body>
</html>
ATTRIBUTES
Following is the list of attributes for <input> tag for creating text field.
Attribute Description
type Indicates the type of input control and for text input control it
will be set to text.
name Used to give a name to the control which is sent to the server to
be recognized and get the value.
value This can be used to provide an initial value inside the control.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title> password input controls</title>
</head>
<body>
<form >
User ID : <input type="text" name="user_id" /> <br>
Password: <input type="password" name="password" />
</form>
</body>
</html>
ATTRIBUTES
Following is the list of attributes for <input> tag for creating password fields.
Attribute Description
type Indicates the type of input control and for password input
control it will be set to password.
name Used to give a name to the control which is sent to the server to
be recognized and get the value.
value This can be used to provide an initial value inside the control.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>Multiple line text input controls</title>
</head>
<body>
<form>
Description : <br />
<textarea rows="5" cols="50" name="description"> Enter description here...
</textarea>
</form>
</body>
</html>
ATTRIBUTES
Following is the list of attributes for <textarea> tag.
Attribute Description
name Used to give a name to the control which is sent to the server
to be recognized and get the value.
row Indicates the number of rows of text area box
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>Multiple line text input controls</title>
</head>
<body>
<form>
<input type="checkbox" name="maths" value="on"> Maths
<input type="checkbox" name="physics" value="on"> Physics
</form>
</body>
</html>
ATTRIBUTES
Following is the list of attributes for <checkbox> tag.
Attribute Description
type Indicates the type of input control and for checkbox input
control it will be set to checkbox.
name Used to give a name to the control which is sent to the server to be
recognized and get the value.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>radio button control</title>
</head>
<body>
<form>
<input type=“radio" name=“subject" value=“maths"> Maths
<input type=“radio" name=“subject" value="physics"> Physics
</form>
</body>
</html>
ATTRIBUTES
Following is the list of attributes for radio button.
Attribute Description
type Indicates the type of input control and for checkbox input
control it will be set to radio.
name Used to give a name to the control which is sent to the server to be
recognized and get the value.
value The value that will be used if the radio box is selected.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>select box control</title>
</head>
<body>
<form>
<select name="dropdown">
<option value="Maths" selected>Maths</option>
<option value="Physics">Physics</option>
</select>
</form>
</body>
ATTRIBUTES
Following is the list of important attributes of <select> tag:
Attribute Description
value The value that will be used if an option in the select box box is
selected.
selected Specifies that this option should be the initially selected value
when the page loads.
Attribute Description
name Used to give a name to the control which is sent to the server
to be recognized and get the value.
size This can be used to present a scrolling list box.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>file upload box</title>
</head>
<body>
<form>
<input type="file" name="fileupload" accept="image/*/”>
</form>
</body>
</html>
ATTRIBUTES
Following is the list of important attributes of <select> tag:
Attribute Description
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>button controls</title>
</head>
<body>
<form>
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" value="Reset" />
<input type="button" name="ok" value="OK" />
<input type="image" name="imagebutton" src="/html/images/[Link]" />
</form>
</body>
ATTRIBUTES
Following is the list of important attributes of <select> tag:
Attribute Description
submit This creates a button that automatically submits a form.
We can re-write above example with the help of Style Sheet as follows:
<!DOCTYPE html>
<html>
<head> <title>HTML CSS</title>
</head>
<body> <p style="color:green;font-size:24px;">Hello, World!</p>
</body>
</html>
HTML STYLE SHEET
You can use CSS in three ways in your HTML document:
• External Style Sheet - Define style sheet rules in a separate .css file
and then include that file in your HTML document using HTML <link>
tag.
• Inline Style Sheet - Define style sheet rules directly along-with the
HTML elements using style attribute.
Let's see all the three cases one by one with the help of suitable
examples.
EXTERNAL STYLE SHEET
If you need to use your style sheet to various pages, then its always
recommended to define a common style sheet in a separate file. A
cascading style sheet file will have extension as .css and it will be
included in HTML files using <link> tag.
EXAMPLE
.red {
color: red;
}
.thick {
font-size:20px;
}
.green {
color:green;
}
EXTERNAL STYLE SHEET
Here we defined three CSS rules which will be applicable to
three different classes defined for the HTML tags. I suggest
you should not bother about how these rules are being
defined because you will learn them while studying CSS.
Now let's make use of the above external CSS file in our
following HTML document:
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>HTML External CSS</title> <link
rel="stylesheet" type="text/css" href="/html/[Link]">
</head>
<body>
<p class="red">This is red</p>
<p class="thick">This is thick</p>
<p class="green">This is green</p>
<p class="thick green">This is thick and green</p>
</body>
</html>
INTERNAL STYLE SHEET
If you want to apply Style Sheet rules to a single document only then you can
include those rules in header section of the HTML document using <style> tag.
Rules defined in internal style sheet overrides the rules defined in an external CSS
file.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>HTML Internal CSS</title>
<style type="text/css"> .red{ color: red; } .thick{ font-
size:20px; } .green{ color:green; }
</style>
</head>
<body>
<p class="red">This is red</p>
<p class="thick">This is thick</p>
<p class="green">This is green</p>
<p class="thick green">This is thick and green</p>
</body>
</html>
INLINE STYLE SHEET
You can apply style sheet rules directly to any HTML element using style attribute
of the relevant tag. This should be done only when you are interested to make a
particular change in any HTML element only.
Rules defined inline with the element overrides the rules defined in an external
CSS file as well as the rules defined in <style> element.
EXAMPLE
<!DOCTYPE html>
<html>
<head> <title>HTML Inline CSS</title>
</head>
<body>
<p style="color:red;">This is red</p>
<p style="font-size:20px;">This is thick</p>
<p style="color:green;">This is green</p>
<p style="color:green;font-size:20px;">This is thick and
green</p> </body>
</html>
THE END
THAT’S ALL FOLKS