HTML & Css Chapter Notes
HTML & Css Chapter Notes
HTML & Css Chapter Notes
By
Upendra sir
Topics:
HTML
CSS
JAVASCRIPT
XML
Topics In HTML:
1. Web terminology [website, webpage]
HTML :
To create webpages and web applications
It is tag based language [Internet language] or browser under stable language
Every tag contains opening and closing tag
Html was introduced by Tim berner's lee in 1991 and published in 1995.
Hyper text means it is a text which navigates to another document
Types of tags:
1. Container tag/pair tags : Having both opening and closing tags <html> </html>
2. Empty tag/single tags : Having only opening tags <br> <hr> <img>
Structure Of Html Program:
<!DOCTYPE html> #standard tag
<html>
<head>
Title information, CSS, SCRIPT TAGS..etc
</head>
<body>
Body of the webpage
</body>
</html>
How to save html program:
we can save html programs either .html or .htm extension
<!DOCTYPE html>
<html>
<head>
<title>welcome to html program</title>
</head>
<body>
welcome to web design course
</body>
</html>
Heading Level Tags:
1. HTML headings are titles or subtitles that you want to display on a webpage.
2. headings are defined with the <h1> to <h6> tags
3. <h1> defines the most important heading. <h6> defines the least important heading.
4. It is important to use headings to show the document structure.
5. <h1> headings should be used for main headings, followed by <h2> headings, then the less important <h3>, and so on.
Headings.html
<!DOCTYPE html>
<html>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</body>
</html>
Note: Browsers automatically add some white space (a margin) before and after a heading.
Bigger Headings:
Each HTML heading has a default size. However, you can specify the size for any heading with the style attribute, using the CSS
font-size property:
<h1 style="font-size:60px;">Heading 1</h1>
Paragraphs:
The HTML <p> element defines a paragraph.
A paragraph always starts on a new line, and browsers
automatically add some white space (a margin) before and after a
paragraph.
Paragraph1.html
<html>
<head>
<title>Paragraph Tag</title>
</head>
<body>
<p>This is first paragraph</p>
<p>This is second paragraph</p>
<p>This is third paragraph</p>
</body>
</html>
NOTE: The browser will automatically remove any extra spaces and lines when the
page is displayed:
Paragraph2.html
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>
<p>
This paragraph
contains a lot of spaces
in the source code,
but the browser
ignores it.
</p>
Horizontal tag:
The <hr> tag defines a thematic break in an HTML page, and is most often
displayed as a horizontal rule.
The <hr> element is used to separate content (or define a change) in an HTML
page:
Horizontal.html
<!DOCTYPE html>
<html>
<body>
<h1>This is heading 1</h1>
<p>This is some text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
</body>
</html>
Line Breaks:
Breaktag.html:
<p>
My Bonnie lies over the ocean.
<html>
<body>
<p>The pre tag preserves both spaces and line breaks:</p>
<pre>
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
</pre>
</body>
</html>
Styles attribute:
The HTML style attribute is used to add styles to an element, such as color, font, size, and more.
Background Color:
CSS background-color property defines the background color for an HTML element.
1. Set the background color for a page to powderblue:
Backgroundcolor.html:
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
Text Size:
The CSS font-size property defines the text size for an HTML element:
Fontsize.html:
<h1 style="font-size:30px;">This is a heading</h1>
<p style="font-size:16px;">This is a paragraph.</p>
Text Alignment:
The CSS text-align property defines the horizontal text alignment for an HTML element:
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
Text Formatting tags:
HTML contains several elements for defining text with a special meaning.
Tag Description:
<b>
Defines bold text
<i>
Defines a part of text in an alternate voice or mood
<sub>
Defines subscripted text
<sup>
Defines superscripted text
<b> Tag:
Make some text bold (without marking it as important):
Bold.html:
<p>This is normal text - <b>and this is bold text</b>.</p>
<p>This is normal text - <span style="font-weight:bold;">and this is bold text</span>.</p>
<i> tag:
The content inside is typically displayed in italic.
Italic.html:
<p><i>Lorem ipsum</i> is the most popular filler text in history.</p>
<p>The <i>RMS Titanic</i>, a luxury steamship, sank on April 15, 1912 after striking an iceberg.</p>
<sub> Element
The HTML <sub> element defines subscript text. Subscript text appears half a character below the normal line, and
is sometimes rendered in a smaller font. Subscript text can be used for chemical formulas, like H2O:
Sub.html
<p>This is <sub>subscripted</sub> text.</p>
<sup> Element
The HTML <sup> element defines superscript text. Superscript text appears half a character above the normal line,
and is sometimes rendered in a smaller font. Superscript text can be used for footnotes, like WWW[1]:
Sup.html
<p>This is <sup>superscripted</sup> text.</p>
HTML - Hypertext Reference (href) or Hyperlinks or Anchors
HTML Anchor
The HTML anchor tag defines a hyperlink that links one page to another page. The "href"
attribute is the most important attribute of the HTML a tag.
Local.html
<a href="first.html" target="_blank">click here</a><br>
<a href="first.html" target="_self">click here</a>
External.html
<body>
<a href="https://www.google.com/" target="_blank">click here</a>
</body>
Images:
The <img> tag is used to embed an image in an HTML page.
The <img> tag has two required attributes:
src - Specifies the path to the image
alt - Specifies an alternate text for the image, if the image for some reason cannot be
displayed
Note: Also, always specify the width and height of an image. If width and height are not
specified, the page might flicker while the image loads.
Images1.html:
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="border:5px solid
black">
Images2. html:
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:bottom">
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-
align:middle">
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:top">
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="float:right">
<img src="smiley.gif" alt="Smiley face" width="42" height="42" style="float:left">
How to add a hyperlink to an image:
Image with hyper link.html
<h1>Add a hyperlink to an image</h1>
<p><a href="https://aaigen.com/">
<img src="https://aaigen.com/wp-content/uploads/2019/10/Aaigen-Technologies-Logo.png" alt="Aaigen.com" width="100"
height="132">
</a></p>
How to add background-image:
Note: For beautiful back ground images visit unsplash.com
Css code:
body{
color: red;
text-align :center;
background:url(https://images.unsplash.com/photo-1551209028-
8bbf88d0044f?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-
1.2.1&auto=format&fit=crop&w=751&q=80);
background-repeat: no-repeat;
background-size: cover;
}
img{
border : 10px solid green;
width: 25%;
height: 250px;
margin: 10px;
}
HTML Lists:
HTML Lists are used to specify lists of information. All lists may contain one or more list elements.
List is one of the most effective ways of structuring a Website or its contents are to use lists.
HTML provides three types of lists:
Ordered List or Numbered List (ol)
Unordered List or Bulleted List (ul)
Description List or Definition List (dl)
Ordered list (or )Numbered List:
In Ordered list, all the list items are marked with numbers.
It is known as numbered list also.
The ordered list starts with <ol> tag and ends with </ol> and the list items start with <li> tag and
</li>
Different numbering schemes can be specified depending upon preference.
A list can number from any value. The starting value is given by the “start” attribute.
Elements of a list may be formatted with any of the usual text formatting tags and may be images or
hyperlinks.
Syntax:
<ol [ type=”1” | “a” | “A” | “I” | “i” ] [ start = “number” ] > … </ol>
Note: <li>…</li>
Unordered list (or) Bulleted List:
• In Unordered list, all the list items are marked with bullets.
• It is also known as bulleted list also.
• The Unordered list starts with <ul> tag and ends with </ul>
• List items start with the <li> tag and </li>.
• Different types of bullet symbols can be specified by using the “type” attribute in
<ul>tag
th, td {
padding: 15px;
}
Table - Left-align Headings
By default, table headings are bold and centered.
To left-align the table headings, use the CSS text-align
property:
th {
text-align: left;
}
Table - Add Border Spacing
Border spacing specifies the space between the cells.
To set the border spacing for a table, use the CSS border-
spacing property:
table {
border-spacing: 5px;
}
Note: If the table has collapsed borders, border-spacing
has no effect.
Table - Add a Caption
To add a caption to a table, use the <caption> tag:
Note: The <caption> tag must be inserted immediately after the <table> tag.
<caption>Monthly savings</caption>
Colspan:
To make a cell span more than one column, use the colspan attribute:
<table border=1>
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>55577854</td>
<td>55577855</td>
</tr>
</table>
Forms
An HTML form is used to collect user input. The user input is most often sent to a server for processing.
The <form> Element
The HTML <form> element is used to create an HTML form for user input:
<form>
form elements
</form>
The <form> element is a container for different types of input elements, such as: text fields, checkboxes, radio buttons, submit
buttons, etc.
Attribute describes the way to send it.
Following are attributes of <form>:
1. Name:
The name attribute specifies the name of a form which is used to reference elements in a JavaScript.
<form name=“Form name">
2. Action:
The required action attribute specifies where to send the form‐data when a form is submitted.
<form action="URL"> Value: URL
3. Method:
The method attribute specifies how to send form‐data (the form‐data is sent to the page specified in the
action attribute).
<form method="get|post">
Available Controls:
Controls are created using <INPUT> tag & TYPE attribute.
1. Form:
<form> … </form> creates an HTML form, used to enclose HTML controls. The attributes are:
Action: Gives the URL which will handle the form data.
Method: Indicates a method or protocol for sending data to the target URL. The Get method is the default.
2. Text Fields:
<input type=”text”> creates a text field that the user can enter or edit text inside it. The
attributes are:
a) size: Sets the size of the control.
b) value: The value entered in the text field.
c) maxlength: sets the maximum number of characters enter in the text field.
3. Password:
<input type=”password”> creates a password text field, which shows asterisks on the text field. The attributes
are:
maxlength: sets the maximum length of the data in the control.
Name: gives the name of the control.
Value: represents the value entered in the text field.
4. Checkbox:
<input type=”checkbox”> creates a checkbox in a form. The attributes are:
Checked: Indicates if the checkbox should appear checked initially or not.
Size: sets the size of the checkbox.
Value: represents the result of the checkbox when clicked, which is passed to the forms action URL.
5. Radio buttons:
<input type=”radio”> creates a radio button in the form. The attributes are:
Checked: Indicates if the checkbox should appear checked initially or not.
Value: represents the result of the checkbox when clicked, which is passed to the forms action URL.
6. Selection lists:
<select> … </select> Creates a drop-down lists, where the user can select choice from the list of elements.
And <option>…..</option> tag is used to provide values . The attributes are:
a) name: represents the name of the control.
b) value: the value of selected item.
7. Submit button:
<input type=”submit”> creates a submit button that the user can click to send data in the form back to web
server. The attributes are:
Name: sets the name of the control.
Value: Text to be displayed on the button.
8. Reset button:
<input type=”reset”> creates a reset button in a form that resets all fields to their original values.
The attributes are:
a) Name: sets the name of the control.
b) Value: Text to be displayed on the button.
9. <Textarea> tag
It is used to specify a text are or multi line text box. In a text area you can write an unlimited characters. It is
mostly use in users feedback, home address etc.
Example:
<textarea cols="5 rows="5" name="Feedback" >
a) cols: It is an attribute which specifies the number of columns in text area
b) rows: It is an attribute which specifies the number of rows in text area
c) name: It Specifies unique name for the input element
10. Image type: Define an image as a submit button:
<Marquee> tag:
The marquee tag is a non-standard HTML element which causes text to scroll up, down, left or right automatically.
Attributes
Marquee's element contains several attributes that are used to control and adjust the appearance of the marquee.
Attribute Description
behavior It facilitates user to set the behavior
of the marquee to one of the three
different types: scroll, slide and
alternate.
direction Defines direction for scrolling
content. It may be left, right, up and
down.
width Defines width of marquee in pixels or
%.
height Defines height of marquee in pixels or
%.
scrollamount provides value for speeding the
marquee feature
Scroll Marquee:
It is a by default property. It is used to scroll the text from right to left, and restarts at the right side of the marquee when it is
reached to the end of left side. After the completion of loop text disappears.
Slide Marquee:
In slide marquee, all the contents to be scrolled will slide the entire length of marquee but stops at the end to display
the content permanently.
Alternate Marquee:
It scrolls the text from right to left and goes back left to right.
Attribute Description
2. CSS Id Selector
Internal/Embedded CSS
This type of CSS is only for Single Page.
When using internal CSS, we must add a new tag, <style>, inside the <head>
tag.
Example:
<p>My mother has <span style="color:blue;font-weight:bold">blue</span> eyes and my father has
<span style="color:darkolivegreen;font-weight:bold">dark green</span> eyes.</p>
Output:
</body>
</html>
<style>
tr:nth-child(odd) {
background-color: #f2f2f2;
}
</style>
Text Transform
• The text-transform property is used to specify uppercase and
lowercase letters in a text.
h5{ text-transform: uppercase; }
h5{ text-transform: lowercase; }
Word Spacing
• With the CSS attribute word-spacing you are able to specify the
exact value of the spacing
Between your words. Word-spacing should be defined with exact values.
p { word-spacing: 10px; }
CSS Letter Spacing
• With the CSS attribute letter-spacing you are able to specify
the exact value of the spacing
Between your letters. Letter-spacing should be defined with exact
values.
p { letter-spacing: 3px; }