Web Designing
Web Designing
HTML Basics
First developed by Tim Berners-Lee in 1990, HTML is short for hypertext markup
language. HTML creates electronic documents (called web pages) that are displayed
on the World Wide Web.
Each page contains several connections to other pages called hyperlinks. Every web
page you see was written using one version of HTML.
HTML code ensures the proper formatting of text and images for your Internet
browser. Without HTML, a browser would not know how to display text
as elements or load images or other elements.
HTML also provides a basic structure of the page, upon which CSS (cascading style
sheets) are overlaid to change its appearance. One could think of HTML as the bones
(structure) of a web page, and CSS as its skin (appearance).
Features of HTML
Let’s practice using these tags and create a web page with them:
Once you have decided on your content and layout, it's time to design your first
HTML page. Start by opening the text editor of your choice. While every webpage is
<!DOCTYPE html>
<html>
<head>
<title>
Your Browser Title text goes here
</title>
</head>
<body>
The contents of your webpage goes here
</body>
</html>
<HTML>…</HTML>
The <html> and </html> tags are the main tags and identify your page as an
HTML document. When a Web browser reads your document, it knows that everything
between these two tags is an HTML document. Each HTML page you create should start
with <!DOCTYPE html>, <html> and end with </html> as shown in the example below.
Now that we understand the basic building blocks of an HTML page, let’s examine
page formatting. When you are working in a word processing program such as Microsoft
Word, you press the “Enter” (or Return) key on your keyboard to begin a new paragraph.
Web browsers do not recognize those line breaks. Instead, you must insert paragraph tags
<p>…</p> each time you want to start a new paragraph.
By default, browsers ignore many formatting keystrokes that we take for granted.
Examples include the “Enter” and “Tab” keys and multiple uses of the spacebar. To
accomplish the same tasks in HTML, we use page formatting tags.
Web browsers wrap text automatically to the next line when the current line
reaches the right side of the browser. If you want to avoid wrapping and begin text on a
new line, you use the <br> tag. The <br> tag does not have an end tag. You can also add
additional lines between paragraphs by using the <br> tags. Each <br> tag you enter
creates another blank line.
Headings:
Creating Headings:
Headings are used on Web pages the same way they are used in printed documents
they break up text into sections.
The HTML standard defines six levels of headings each one progressively smaller in
font size, <h1> through <h6>.
Heading 1
[Type text] Page 5
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Entity:
Example: <p>This would add five
blank spaces.</p>
Result: This would add five blank spaces.
Creating Headings:
Headings are used on Web pages the same way they are used in printed documents
they break up text into sections.
The HTML standard defines six levels of headings each one progressively smaller in
font size, <h1> through <h6>.
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading.
Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Output:
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
HR Tag
The <hr> tag is an empty element. This means that it only has an opening tag, <hr>.
Starting in HTML5, we now need to attach a slash to the tag of an empty element. So,
instead of having just <hr>, you should make it <hr />.
In browsers, the <hr /> tag is displayed as a horizontal rule or line, like this:
List Tag
The <li> tag is used if you want to enter the contents in the listed order. There are two types
of lists.
Ordered list <ol>
Unordered list <ul>
You can insert lists into your HTML documents to display ordered lists of items.
Numbered lists (sometimes called Ordered Lists) are generally used to list items by their
priority or their sequence in a process. For example, you might use a numbered list to display
instructions in completing a specific task.
When you create a numbered list, you must use two different tags. First, you place the
<ol>…</ol> tags around the text you want to become a numbered list. Second, you place the
<li>…</li> tags around each line of the list. You have five choices when creating numbered
lists: Upper-case letters (A,B,C), lower-case letters (a,b,c), upper-case Roman numerals
(I,II,III), lower-case Roman numerals (I,ii,iii) and regular numbers (1,2,3) which is the
default. You define the type of numbered list you want by using the TYPE attribute and
placing it within the <ol> start tag. You can also begin the numbering (ordering) at any point
in the sequence as well using the START attribute. For example, if you wanted to start your
list with item D, you would use the attribute start=“D” by placing it within the <ol> start tag as
well..93
The other type of list you can create is called a bulleted (also called unordered) list.
Bulleted lists are typically used when items require the reader’s attention, but do not need
to be listed in any particular order.
When you create a bulleted list, you must use two different tags. First, you place
the <ul>…</ul> tags around the text you want to become a bulleted list. Second, you
place the <li>…</li> tags around each line of the list. You have three choices when
creating bulleted lists: Circles (○), squares (■) and discs (●) which is the default. You
define the type of bulleted list you want by using the STYLE attribute and the value of
“list-style-type:“?” (where ? Is circle, square or disc) placing it within the <ul> start tag.
Start Tag:
<dl>
End Tag:
</dl>
Attributes:
None
Related Tags: <dt>…</dt> (Definition Term)
<dd>…</dd> (Definition)
Example: What do the applications do? These tags will create a
<dl> definition list.
<dt>Access</dt>
<dd>Create databases and programs to
track and manage your information</dd>
<dt>Excel</dt>
<dd>Perform calculations, analyze
information and manage lists in
spreadsheets</dd>
</dl>
Result: What do the applications do?
Access
Create databases and programs to
track and manage your information.
Excel
Perform calculations, analyze
information and manage lists in
spreadsheets.
!
Decoration:
The TEXT-DECORATION property is used to add strike-through marks,
underline and overstrike marks to your text. Generally this property is used to remove
underlines from links. For example, a link in the middle of a sentence that is already
underlined, will stand out more if is not underlined. It is generally good practice to not
underline text that isn’t a link as it can be confusing to some users.
Property: text-decoration
Example: p {text-decoration:
underline;} a {text-
decoration: none;}
Result: Sets the CSS rule to underline all text of your
paragraphs and sets the rule to NOT underline
any links.
1. Fonts:
To control the fonts in a CSS style rule, use the FONT-FAMILY property. When
using the FONT- FAMILY property you want to list several fonts as not all fonts are
supported by all browsers. Your user’s browser will attempt each of the fonts, in the order
they are listed. When listing multiple fonts they are separated by a comma. For example:
listing Arial, Helvetica, “Times New Roman” will display Arial, if available, then try
Helvetica, then Times New Roman, and so on. When adding font values to the FONT-
FAMILY property, you only need to use quotes with multiple word fonts, like “Times
New Roman”.
Property: font-family
Result: Sets the CSS rule to apply the verdana font first, then
georgia to the text of paragraphs.
Font Sizes:
The FONT-SIZE property allows you to create a CSS rule that controls the size of
the font. The value you assign can be a numerical value in the form of pixels (px), inches
(in), millimeters (mm), centimeters (cm), points (pt), picas (pc), x-height (ex), em (the
Property: font-size
Property: line-height
You can use the COLOR property to control the color of text. You can assign
either a hexadecimal value or use the name of a color. The COLOR property can also
be applied to other elements such as tables, borders and lines.
Property: color
Result: Sets the CSS rule to apply a maroon font color to all
level 1 headings.
<body>
<p>This is a paragraph and <big>bigger text goes here</big></p>
</body>
Sample Output
TABLES:
HTML Table
HTML table tag is used to display data in tabular form (row * column). There can be many
columns in a row.
We can create a table to display data in tabular form, using <table> element, with the help of
<tr> , <td>, and <th> elements.
In Each table, table row is defined by <tr> tag, table header is defined by <th>, and table data
is defined by <td> tags.
HTML tables are used to manage the layout of the page e.g. header section, navigation bar,
body content, footer section etc. But it is recommended to use div tag over table to manage
the layout of the page .
Tag Description
<col> It is used with <colgroup> element to specify column properties for each
column.
Let's see the example of HTML table tag. It output is shown above.
<table>
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
<tr><td>James</td><td>William</td><td>80</td></tr>
<tr><td>Swati</td><td>Sironi</td><td>82</td></tr>
<tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
</table>
Output:
First_Name Last_Name Marks
Sonoo Jaiswal 60
James William 80
Swati Sironi 82
Chetna Singh 72
Output:
HTML <caption> tag is used to add a caption or title of an HTML table. It should be used
inside the <table> element and just after the <table> start tag. A table may contain only one
<caption> element.
Syntax
<caption>Table title...</caption>
Display Inline
Usage textual
Output:
Frames:
HTML <frameset> tag
HTML <frameset> tag is used to contain the group of frames which can be controlled and
styled as a unit. The <frameset> element also specifies the number of rows and columns in
the frameset, and how much space they will occupy in a frame.
Syntax
<frameset cols=" ">............</frameset>
Attribute
Tag-specific attribute
cols Pixels % * It specifies the number and size of column spaces in the
frameset. (Not Supported in HTML5)
Rows Pixels % * It specifies the number and size of the rows spaces in the
frameset. (Not Supported in HTML5)
What is an Iframe?
An Iframe (Inline Frame) is a separate HTML document that is embedded into
your HTML document. The most common usage of the Iframe element is to insert
Graphics
Graphics are representations used to make web-page or applications visually
appealing and also for improving user experience and user interaction.
Some examples of graphics are photographs, flowcharts, bar graphs, maps,
engineering drawings, constructional blueprints, etc. Usually, the following
technologies are used in web graphics.
There are two modern web technologies for creating rich drawn graphics within the
browser:
HTML5 Canvas and Scalable Vector Graphics (SVG).
1. About Forms
Forms are used to collect information from people who visit your website. For
example, you can use forms to find out details about your visitors through surveys
and feedback, or engage in e-commerce by selling your goods and services to
people.
Forms are defined by the <form>…</form> tags and are made up of different
elements to collect data, such as text boxes and radio buttons. Once the user
inputs all of the information, they submit the form, using the “submit” button that
you create. What happens with the data is a decision you will need to make. You
can use a script to manage the data, sent the data to a database, or even receive the
[Type text] Page 22
data via e-mail.
Most forms are processed using CGI scripts, CGI (Common Gateway Interface)
is a script written in a language such as Java or Perl and runs on a Web server.
Most Web servers accommodate the processing of CGI scripts, but you should
check first with your Web host to make sure.
In addition, you will want to find out the location of the server’s CGI-bin (a
directory where CGI scripting is stored), as this is where you will need to store
the CGI script you create or use.
If you know a language such as Perl, you can write your own script. There are
also hundreds of free scripts available online that you can use, such as the ones at
sites like The CGI Resource Index (http://www.cgi.resourceindex.com) and
JavaScript Kit (http://www.javascriptkit.com).
You will need to make the necessary changes to the CGI script that you use
(script variables, path names, etc.) and upload the CGI script to your Web host
server.
To begin creating a form using CGI script, start with the <form> tag, containing
the command (method=“post”) and the ACTION attribute, with a value equal to
the path and name of your CGI script.
2.Sending to E-mail:
If your Web server does not support CGI scripting, or if you prefer to avoid it
altogether, you can send the form data directly to an e-mail address. Keep in mind that this
is not a good solution if you are capturing sensitive data such as credit card numbers, as it
is not a secure form of transmission. Sending your form data to an e-mail address is a good
solution if your form is simple.
To send the information to an e-mail address, you use the following coding:
3.Text Boxes:
Text boxes are the most basic elements that forms use in the collection of data.
Text boxes are typically used when the input requires a single line of text. To create a text
box, you use the <input> element tag and TYPE attribute with a value of “text” and place
it between the <form>…</form> tags. You must also specify a unique name for the text
box using the NAME attribute.
By default, text boxes are 20 characters wide. You can change the width of the
field that is displayed by using the SIZE attribute. You can also limit the number of
characters the user can type into the text box by using the MAXLENGTH attribute.
Sometimes, you will want to collect text from individuals that requires a larger
box. This is common in situations where you ask for feedback that may require multiple
sentences. In this case, you can insert a large text area using the <textarea>…</textarea>
element tags and assigning a unique (and required) name using the NAME attribute.
You control the dimensions of the text area using the COLS and ROWS attributes,
measured in relation to the character height. You can also control how text wraps within
the text area using the WRAP attribute. You have three choices when assigning a value to
the WRAP attribute: “soft”, “hard”, and “off”. A value of “soft” will wrap the text in your
area, but will not wrap text in the form results (meaning it will be in a single field in a
database or a single line in an e-mail). The value “hard” wraps text in both the text area
and form results. The value “off” turns text wrapping completely off and forces users to
create new lines using the “Enter” key on their keyboard.
If the user types more characters than can be seen in the text area you created,
scroll bars will appear to enable viewing of the text. Text areas hold up to 32,700
5.Check Boxes:
Check boxes are used when you want visitors to select from one or more options
that you present. To create check boxes, you use the <input> element tag and TYPE
attribute with a value of “checkbox” and place it between the <form>…</form> tags. You
can group the check boxes using the same NAME attribute for each element. Remember
that the value you assign is a description of the checkbox. If you want your check boxes to
all appear on a separate line, use the <p> or <br> tags before each element.
5.Menu Lists:
Menu lists are typically used when you have a long list of choices to give users.
The menu list appears as a drop-down list and allows the user to select their choice.
Between the <form>…</form> tags, use the <select> element tag, along with the NAME
attribute and define a size for the box with the SIZE attribute (measured in character
lines). The <option> element tag is then used to define each of the choices in the menu.
7.Radio Buttons:
Radio buttons are the small circles (O) that appear in forms. Radio buttons allow
you to present a series of choices (grouped under the same NAME attribute) but only
allows the user to select a single choice. To add radio buttons, use the <input> element tag
between the <form>…</form> tags with a TYPE value of “radio”. The <p> or <br> tags
allow you to position each choice on its own line.
8.Submit Button:
The submit button is a required piece of your form since when it is clicked, it
actually sends the data to be processed. You must have a submit button in your form in
order to receive the data. Using the
<input> element tag and a value of “submit” for the TYPE attribute, assign a VALUE
that is the text you want to appear in the button (typically “Submit”).
9.Reset Button:
The reset button is used to allow a user to clear all of the information they have
entered into a form. To insert a reset button, use the <input> element tag with a TYPE
attribute and a value of “reset”, and the VALUE attribute with a value that is the text you
want to appear in the button (typically “Reset”).
Attributes: type=“reset”
Users can navigate through the elements of your form by using the Tab key on
their keyboard, jumping from one element to the next. By default, the order the Tab key
follows is the order in which you entered the form elements in your HTML page. To
change the tab order, add the TABINDEX attribute to your element tags and assign a
numeric value for the position you want (“1” for 1st, “2” for 2nd and so on.)
Actions of Forms
1. Create a form that uses a cgi script:
2. Create a form that sends information to an e-mail address:
3. Add a text box to a form:
4. Add a text area to a form:
5. Add check boxes to a form:
6. Add a menu list to a form:
7. Add radio buttons to a form:
8. Add a (required) submit button to a form:
9. Add a reset button to a form:
10. Change the tab order:
<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">
Input Type Text
Example
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
First name:
Last name:
Example
Username:
Password:
The form-handler is typically a server page with a script for processing input data.
Example
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
Last name:
Doe
Submit
If you omit the submit button's value attribute, the button will get a default text:
Example
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<input type="reset"> defines a reset button that will reset all form values to their default
values:
Example
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
First name:
John
Last name:
Doe
Submit Reset
If you change the input values and then click the "Reset" button, the form-data will be reset to
the default values.
Radio buttons let a user select ONLY ONE of a limited number of choices:
Example
<p>Choose your favorite Web language:</p>
<form>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
[Type text] Page 31
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
HTML
CSS
JavaScript
Input Type Checkbox
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
Example
<form>
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label>
</form>
I have a bike
I have a car
I have a boat
Example
<input type="button" onclick="alert('Hello World!')" value="Click Me!">
Depending on browser support, a color picker can show up in the input field.
Example
<form>
<label for="favcolor">Select your favorite color:</label>
<input type="color" id="favcolor" name="favcolor">
</form>
Input Type Date
The <input type="date"> is used for input fields that should contain a date.
Depending on browser support, a date picker can show up in the input field.
Example
<form>
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday">
</form>
You can also use the min and max attributes to add restrictions to dates:
Example
<form>
<label for="datemax">Enter a date before 1980-01-01:</label>
<input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br>
<label for="datemin">Enter a date after 2000-01-01:</label>
<input type="date" id="datemin" name="datemin" min="2000-01-02">
</form>
The <input type="datetime-local"> specifies a date and time input field, with no time zone.
Depending on browser support, a date picker can show up in the input field.
Example
<form>
<label for="birthdaytime">Birthday (date and time):</label>
<input type="datetime-local" id="birthdaytime" name="birthdaytime">
</form>
Input Type Email
[Type text] Page 33
The <input type="email"> is used for input fields that should contain an e-mail address.
Depending on browser support, the e-mail address can be automatically validated when
submitted.
Some smartphones recognize the email type, and add ".com" to the keyboard to match email
input.
Example
<form>
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email">
</form>
Input Type Image
Example
<form>
<input type="image" src="img_submit.gif" alt="Submit" width="48" height="48">
</form>
Input Type File
The <input type="file"> defines a file-select field and a "Browse" button for file uploads.
Example
<form>
<label for="myfile">Select a file:</label>
<input type="file" id="myfile" name="myfile">
</form>
The <input type="hidden"> defines a hidden input field (not visible to a user).
A hidden field lets web developers include data that cannot be seen or modified by users
when a form is submitted.
A hidden field often stores what database record that needs to be updated when the form is
submitted.
Note: While the value is not displayed to the user in the page's content, it is visible (and can
be edited) using any browser's developer tools or "View Source" functionality. Do not use
hidden inputs as a form of security!
The <input type="month"> allows the user to select a month and year.
Depending on browser support, a date picker can show up in the input field.
Example
<form>
<label for="bdaymonth">Birthday (month and year):</label>
<input type="month" id="bdaymonth" name="bdaymonth">
</form>
Input Type Number
The following example displays a numeric input field, where you can enter a value from 1 to
5:
Example
<form>
<label for="quantity">Quantity (between 1 and 5):</label>
<input type="number" id="quantity" name="quantity" min="1" max="5">
</form>
The <input type="range"> defines a control for entering a number whose exact value is not
important (like a slider control). Default range is 0 to 100. However, you can set restrictions
on what numbers are accepted with the min, max, and step attributes:
Example
<form>
<label for="vol">Volume (between 0 and 50):</label>
<input type="range" id="vol" name="vol" min="0" max="50">
</form>
The <input type="search"> is used for search fields (a search field behaves like a regular text
field).
Example
<form>
<label for="gsearch">Search Google:</label>
<input type="search" id="gsearch" name="gsearch">
</form>
Input Type Tel
The <input type="tel"> is used for input fields that should contain a telephone number.
Example
<form>
<label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}">
</form>
Input Type Time
The <input type="time"> allows the user to select a time (no time zone).
Depending on browser support, a time picker can show up in the input field.
Example
<form>
<label for="appt">Select a time:</label>
<input type="time" id="appt" name="appt">
</form>
Input Type Url
The <input type="url"> is used for input fields that should contain a URL address.
Depending on browser support, the url field can be automatically validated when submitted.
Some smartphones recognize the url type, and adds ".com" to the keyboard to match url input.
Example
<form>
<label for="homepage">Add your homepage:</label>
<input type="url" id="homepage" name="homepage">
</form>
Input Type Week
The <input type="week"> allows the user to select a week and year.
Example
<form>
<label for="week">Select a week:</label>
<input type="week" id="week" name="week">
</form>
The HTML <form> element can contain one or more of the following form elements:
<input>
<label>
<select>
<textarea>
<button>
<fieldset>
<datalist>
<output>
<option>