training file
training file
1
Varun kumar/CSE-B
HTML – OVERVIEW
HTML stands for Hypertext Markup Language, and it is the most widely
used language to Write Web Pages. HTML is the building block for web
pages. Originally, HTML was developed with the intent of defining the
structure of documents like Headings, paragraphs, lists, and so forth to
facilitate the sharing of scientific information Between researchers.
o The text between the <title> tage is the title of your document. The
<title> tag is used to uniquely Identify each document and is also
displayed in the title bar of the browser window.
o The text between the <body> tags is the text that will be displayed in
your browser.
2
Varun kumar/CSE-B
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.
1. HEADINGS:
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>.
2. PARAGRAPHS:
Paragraphs are defined with the tag. Think of a paragraph as a block of text.
You can use the align attribute with a paragraph tag as well.
<p align="left">This is a paragraph</p>
<p align="center">this is another paragraph</p>
3
Varun kumar/CSE-B
3. LINE BREAKS:
The <br> tag is used when you want to start a new line, but don't want to
start a new paragraph. The<br> tag forces a line break wherever you place
it. It is similar to single spacing in a document .
This Code Would display
<p>This <br> is a para <br> graph This
with is a para
line breaks</p> graph with line breaks
4. HORIZONTAL RULE:
The <hr> element is used for horizontal rules that act as dividers between sections, like
this:
The horizontal rule does not have a closing tag. It takes attributes such as align and
width. For instance:
5. COMMENTS IN HTML:
The comment tag is used to insert a comment in the HTML source code. A comment can
be placed anywhere in the document and the browser will ignore everything inside the
brackets. You can use comments to write notes to yourself, or write a helpful message to
someone looking at your source code.
Note: You need an exclamation point after the opening bracket <!-- but not
before the closing bracket -->.
4
Varun kumar/CSE-B
HTML automatically adds an extra blank line before and after some elements, like before
and after a paragraph, and before and after a heading. If you want to insert blank lines
into your document, use the tag.
5
Varun kumar/CSE-B
NON-BREAKING SPACES
The most common character entity in HTML is the non-breaking space .
Normally HTML will truncate spaces in your text. If you add 10 spaces in your text, HTML
will remove 9 of them. To add spaces to your text, use the character entity.
6
Varun kumar/CSE-B
HTML-ELEMENTS
</br>
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.
Attribute names and attribute values are case-insensitive. However, the
World Wide Web Consortium (W3C) recommends lowercase
attributes/attribute values in their HTML 4 recommendation .
Example:
Core Attributes:
The four core attributes that can be used on the majority of HTML elements
(although not all) are:
8
Varun kumar/CSE-B
There are many attributes which are used in html for multiple purposes will
be discussed below:
HTML – BACKGROUNDS:
The <body> tag has two attributes where you can specify backgrounds. The
background can be a color an image.for background color bgcolor is used
and for background image background is used as below:
This code Would Display
1. <body bgcolor=”red”>
</body>
2. <body background=”/img1”>
</body>
HTML – COLORS:
Colors are defined using a hexadecimal notation for the combination of red,
green, and blue color values (RGB). The lowest value that can be given to
one light source is 0 (hex #00). The highest value is 255 (hex #FF). This
table shows the result of combining red, green, and blue:
Color Color HEX Color RGB
#000000 rgb(0,0,255)
#FF0000 rgb(255,0,0)
#00FF00 rgb(0,255,0)
#0000FF rgb(0,0,255)
#FFFF00 rgb(255,255,0)
9
Varun kumar/CSE-B
#00FFFF rgb(0,255,255)
#FF00FF rgb(255,0,255)
#C0C0C0 rgb(192,192,192)
#FFFFFF rgb(255,255,255)
10
Varun kumar/CSE-B
HTML-LISTS
HTML provides a simple way to show unordered lists (bullet lists) or ordered
lists (numbered lists).
Unordered lists:
An unordered list is a list of items marked with bullets (typically small black
circles). An unordered list starts with the <ul> tag. Each list item starts with
the <li> tag.
</dl>
HTML-LINKS
HTML uses the <a> anchor tag to create a link to another document or web
page.
Email links:
To create an email link, you will use your email address.
12
Varun kumar/CSE-B
HTML-IMAGES
The Image Tag and the Src Attribute:
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 syntax of defining an
image:
This code Would display
<img src="graphics/chef.gif">
Without dimensions, when it runs into an image, the browser has to pause
loading the page, load the image, then continue loading the page. The chef
image would then be:
<img src="graphics/chef.gif" width="130px" height="101px" alt="Sun
with trees">
HTML-TABLE
Tables are defined with the <table> tag. A table is divided into rows
(with the <tr> tag), and each row is divided into data cells (with the
<td> tag). The letters td stands for table data, which is the content of
a data cell. A data cell can contain text, images, lists, paragraphs,
forms, horizontal rules, tables, etc.
Table Tags:
Tag Description
<table> Defines a table
<th> Defines a table header
<tr> Defines a table row
<td> Defines a table cell
<caption> Defines a table caption
<colgroup> Defines groups of table colums
<col> Defines the attribute values for one or more columns
in a table
Example:
This code Would display
<table> row 1, cell 1 row 1, cell 2
<tr> row 2, cell 1 row 2, cell 2
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
14
Varun kumar/CSE-B
</tr>
</table>
TABLE ATTRIBUTES :
This code Would display
1. Border attribute Border=”0”
row 1, cell 1 row 1, cell 2
<table border=”0”> row 2, cell 1 row 2, cell 2
<tr>
<td>row 1, cell 1</td> Border=”1”
<td>row 1, cell 2</td> row 1, cell 1 row 1, cell 2
</tr> row 2, cell 1 row 2, cell 2
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
2. Cell spacing Attribute
15
Varun kumar/CSE-B
3. Cellpadding Attribute
<table border="1"
cellpadding="10">
<tr>
<td>some text</td>
<td>some text</td>
</tr><tr>
<td>some text</td>
<td>some text</td>
</tr>
</table>
4. Colspan attribute
<table border="1">
<tr>
<th>Category</th>
<th colspan="3">Examples</th>
</tr> Category Examples
<tr> Fruits Apples Oranges Grapes
<td>Fruits</td>
<td>Apples</td>
<td>Oranges</td>
<td>Grapes</td>
</tr>
</table>
5. Rowspan attribute Department: Accounting
Freya Olsen
Contact Person:
<table border="1"> Maita Cot
<tr>
<th>Department:</th>
<td>Accounting</td>
</tr>
<tr>
<th>rowspan="2">ContactPerso
n:</th>
<td>Freya Olsen</td>
</tr>
16
Varun kumar/CSE-B
<tr>
<td>Maita Cot</td>
</tr>
</table>
HTML-FORMS
HTML forms provide a great way to capture data from your web site. A form
in an HTML page can be used to submit data to a server for further
processing. Each HTML form is introduced by the <form> tag, and is made
up of different input elements. The <form> tag has several attributes that
would tell the browser what to do with the information that is entered in the
different fields. These attributes are:
● action
● method
The action attribute tells your browser the location of the cgi script that you
are going to use to process the form. On the other hand, the method
attribute has two possible values, method=get or method=post, both of
which specify a method of submitting data to the script you have specified
in the action attribute.
FORM FIELDS :
Any HTML form can contain the following fields. First you have the input
elements:
17
Varun kumar/CSE-B
Text
Password
Checkbox
Radio
Submit
Reset
File
Hidden
Image
Button
There are also other input methods that may be used in an HTML form,
including dropdown lists, radio buttons, check boxes, text areas and others.
Let us see how each of these text elements is used in an HTML form.
EXAMPLES :
This code Would display
Text input:
<form>
<input type="text" id="name"
Click here to enter text
name="name" placeholder="Click
here to enter text">
</form>
id="reading" name="interest"
value="reading"> Reading
</form>
Radio Buttons:
<form>
<label>Choose Your Preferred
Payment Method:</label>
<input type="radio" id="creditCard"
name="paymentMethod"
Choose Your Preferred Payment
value="creditCard"> CreditCard Method:
<br> CreditCard
<input type="radio" id="paypal"
paypal
Music name="paymentMethod"
value="paypal"> Paypal <br> bitcoin
<input type="radio" id="bitcoin"
name="paymentMethod"
value="bitcoin"> bitcoin <br>
</form>
Submit Buttons:
<form>
<button
type="submit">Submit</button> Submit Reset
<button type="Reset ">Reset
</button>
</form>
Example of Forms with Html Table : Program 1
<body >
<div style="display:flex; justify-content:center;">
</td>
</tr>
<!--2nd row-->
<tr>
<td></td> <!--for extra space-->
<td style="text-align: center; font-weight:550; text-decoration:
underline;">B.TECH 1<sup>st</sup> Year</td>
<th rowspan="5"> <!--for display a picture over 5 rows-->
<input style="border: 1px solid black; display: flex; " class="image"
type="file" onchange="readURL(this)" accept="image/*" >
<div style="display: flex; font-size: small;">Student's Photograph</div>
</th>
</tr>
<!--3rd row-->
<tr height="10px">
<!--for extra space-->
</tr>
<!--4th row-->
<tr>
<td >1. Name:</td>
<td id="A"><input type="text" placeholder="NAME" ></td>
</tr>
<!--5th row-->
<tr>
<td>2. Father's Name:</td>
<td id="A"><input type="text" placeholder="NAME" ></td>
</tr>
<!--6th row-->
<tr>
<td>3.Mother's Name:</td>
<td id="A"><input type="text" placeholder="NAME" ></td>
</tr>
<!--7th row-->
<tr>
<td>4.Date of Birth:</td>
<td id="A"><input type="date" ></td>
</tr>
<!--8th row-->
<tr>
<td>5.Gender:</td>
<td id="A">
<input type="radio" id="male" name="gender" value="Male" >
<label for="male">Male</label>
<input type="radio" id="Female" name="gender" value="FeMale" >
<label for="Female">Female</label>
</td>
</tr>
<!--9th row-->
<tr>
<td>6.Nationality:</td>
20
Varun kumar/CSE-B
</tr>
<!--11th row-->
<tr>
<td >8.Mobile No.</td>
<td id="A" ><input type="number" placeholder="91+ 0000000000" ></td>
</tr>
<!--12th row-->
<tr>
<td ><label for="field">9.Branch</label></td>
<td id="A" ><select id="branch" name="field" placeholder="branch" >
<option>CSE</option>
<option>CSE AIML</option>
<option>ECE</option>
<option>EE</option>
<option>ME</option>
<option>CE</option>
</select>
</td>
</tr>
<!--13th row-->
<tr>
<td>8.Qualification</td>
<td style=" display: flex; justify-content: center; width:100%; padding:px;
margin: 0px;">
<input type="file" style="overflow: hidden; color: transparent; width: 100%;"
> <input type="file" style="overflow: hidden; color: transparent; width: 100%;" >
</td>
</tr>
<!--15th row-->
<tr height="px">
<td ></td>
<td id="A" style=" position: relative; bottom: 20px;"><pre>10th Certificate
12th Certificate</pre></td>
</tr>
</table>
</div>
<button type="button" style=" border-radius: 5px; width: 11%; height: 4.5vh;
background-color:#002ead ; position: relative; left: 35%; color: aliceblue; box-
shadow: 1px 1px 1px 1px black;">Submit</button>
21
Varun kumar/CSE-B
OUTPUT_SCREEN
22
Varun kumar/CSE-B
CSS – OVERVIEW
Advantages of CSS:
CSS saves time
Pages load faster
23
Varun kumar/CSE-B
Easy maintenance
Superior styles to HTML
Global web standards
CSS Comments:
Many times, you may need to put additional comments in your style sheet
blocks. So, it is very easy to comment any part in style sheet. You can
simple put your comments inside /*.....this is a comment in style sheet.....*/.
You can use /* ....*/ to comment multi-line blocks in similar way you do in C
and C++ programming languages.
CSS-INCLUSION
1.The Inline CSS: <style> Attribute:
You can use style attribute of any HTML element to define style rules. These
rules will be applied to that element only.
24
Varun kumar/CSE-B
rel=”stylesheet” }
href=”Mystyle.css” h2{
> align:right;
</head> color:blue;
<body> }
<h1>im in center
</h1>
<h2>im in right </h2>
</body>
CSS-SYNTAX
A CSS comprises of style rules that are interpreted by the browser and then
applied to the corresponding elements in your document. A style rule is
made of three parts:
Selector: A selector is an HTML tag at which a style will be applied.
This could be any tag like <h1> or <table> etc.
Property: A property is a type of attribute of HTML tag. Put simply, all
the HTML attributes are converted into CSS properties. They could be
color, border, etc.
Value: Values are assigned to properties. For example, color property
can have the value either red or #FF0000etc.
Selectors:
CSS-Measurement Units
CSS supports a number of measurements including absolute units such as
inches, centimeters, points, and so on, as well as relative measures such
as percentages and em,px units. You need these values while specifying
27
Varun kumar/CSE-B
CSS-Properties
COLOR-Property:
CSS uses color values to specify a color. Typically, these are used to set a
color either for the foreground of an element (i.e., its text) or for the
28
Varun kumar/CSE-B
background of the element. They can also be used to affect the color of
borders and other decorative effects. You can specify your color
values in various formats.
Following table lists all the possible formats:
Format Syntax Example
1. Hex code(RGB) #FFFFFF p
{color:#FFFFFF;
}
2. keyword Red,blue,green p{
color: red;
}
3. rgb (0-255) rgb(255,255,255) p{
color:rgb(255,255,255);
}
BACKGROUND-Properties:
Property This code Would display
1. background- <p style="background- This text has a yellow background
color: color:yellow;"> color.
property used to set the This text has a yellow
backround color. background color.
</p>
2. background- <body background-
image: image:url(“graphics/chef
property used to set .gif”)>
background image. </body>
FONT-properties:
Property This code Would display
1. font-family: <p style="font-family:arial;"> This text has font
property is used to change This text has font family arial. family arial.
29
Varun kumar/CSE-B
NOTE: In above and below Examples we use style attribute to Add CSS in
our html document .
TEXT-properties:
Property This code Would display
1. text-align: <p style="text-align:center;"> This text aligned to
property is used to align the This text is aligned to center. center.
text of a document. </p>
2. text-decoration: <p style=”text- This text is underlined.
property is used to decoration:underline;”>
underline, overline, and This text is underlined</p>
strikethrough text.
3. text-transform: <p style=”text- THIS TEXT IS
property is used to capitalize transform:uppercase”> UPPERCASE.
text or convert text to This text is uppercase</p>
uppercase or lowercase
letters
30
Varun kumar/CSE-B
shadow .
CSS-BOX MODEL
NOTE: Total element width = width + left padding + right padding + left border
+ right border + left margin + right margin.
SIZE-properties:
31