HTML and Javascript Notes
HTML and Javascript Notes
SUBJECT: COMPUTER
CLASS: 8
SESSION - 2024-25
HTML,CSS & JAVASCRIPT NOTES
HTML stands for Hypertext Markup Language. It is a language used to create and format a web page
document.
Tags-
Whatever we put between the angular brackets <--------> is called a tag.
Tags Description
<html>____</html> This is the first tag with which every single web page starts
<head>____</head> This tag allows us to include external files on our website and create a
heading for our title bar.
<title>____</title> This tag creates a heading that will appear at the title bar of the browser.
<body> _______ This is the main tag inside which all our HTML code will reside.
</body>
<h1>____ </h1> This tag allows us to create headings with different font sizes.
<h6>_____ </h6>
div
The div tag is used in HTML to make divisions of content in the web page
images, header, footer, navigation bar, etc).Example -
<div class="myDiv">
<h2>This is a heading in a div element</h2>
<p>This is some text in a div element.</p>
</div>
center refers to the alignment of content in the middle of a container, whether it's
text, images, or other elements.
align is used to adjust the horizontal positioning of content within its containing
element. It specifies whether the content should be left-aligned,
right-aligned, centered, or justified.
height refers to the vertical dimension of an element, such as an image, a
container, or a table row.
<img> The <img> tag is used to embed an image in an HTML page.The <img>
tag has two required attributes:
Example-
<form> An HTML form is used to collect user input. The user input is most often
sent to a server for processing.
<input type="radio"> Displays a radio button (for selecting one of many choices), it comes up in
circle shape
<textarea> The <textarea> element defines a multi-line input field (a text area):
<label> The <label> tag defines a label for many form elements.
The <label> element is useful for screen-reader users, because the
screen-reader will read out loud the label when the user focuses on the
input element.
Class Class is an attribute in HTML used to apply CSS to a specific set of content
Class attribute Class is an HTML attribute used to identify any HTML element (div,
headings, paragraphs, etc) on a webpage. Classes are useful when the
same HTML elements appear several times on a webpage.
Font element Font element is used to change the size, font style and color of the text in
the web page. This is a container element.
Font Size Font size attribute is used to set the size of the text. By default the font size
of the text is 3. We can change the font size according to our requirement
and choice.
FONT FACE Font Face is used to give the type of font like Arial, Lucida etc. face
attribute is browser dependent as some face may not work on any browser
in that case browser uses its default face.
FONT COLOR The font color attribute is used to give the color to the text. By default the
font color is black.
<FONT COLOR=”green”>
What is CSS : Cascading Style Sheet or CSS is a style sheet language used to design and layout a web
page. CSS lets us modify colors, fonts, text sizes, apply animations, effects and more. CSS files have the
extension .css .
Using CSS on a webpage
Syntax:
<start tag style =”property: value”> content </end tag>
Properties in the style attribute are color, background-color, font-size etc.
Value sets the property. For example, color attributes can have values like red, blue, green etc.
Colon (:)sets the value for an attribute.
Semi-colon (;) is used as a separator between two properties.
Example:
<P style=”background-color:red”> This is an Introduction to CSS! </p>
This is an Introduction to CSS! ←—OUTPUT
Class selector: The class selector selects elements with a specific class attribute. It matches all the HTML
elements based on the contents of their class attribute. The . symbol, along with the class name, is used
to select the desired class.
ID selector : The ID selector matches an element based on the value of its id attribute. In order for the
element to be selected, its ID attribute must exactly match the value given in the selector. The # symbol
and the id of the HTML element name are used to select the desired element.
Internal CSS : All the CSS code is added at a single place inside the <head> tag.
A special element <style></style> is added with CSS instructions written inside the <style> tags.
The <style> tag is used to define style information (CSS) for a document.
Syntax - <style>
h1 {color:red;}
p {color:blue;}
</style>
External CSS : This is the last and the most commonly used method to apply CSS. We create a separate file
for all the CSS code. The file extension is .css
Syntax-
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Semantic Elements : A semantic element clearly describes its meaning to both the browser and the
developer.
Examples of non-semantic elements: <div> and <span> - Tells nothing about its content.
Examples of semantic elements: <form>, <table>, and <article> - Clearly defines its content.
JavaScript
▪ JavaScript is a scripting language used to write programs that run on browsers.
▪ JavaScript controls how a web page looks or responds when a user presses a key or moves the mouse.
▪ The suggestions we receive on Google, Amazon, or YouTube are coded using JavaScript.
To add functionality to the application, we need variables. For a program to use data,
we need ‘Variables’. ‘Variables’ are like containers that store data. ‘Data’ refers to the information on which a
computer program operates.
For example, names, ages, and employees in an organization are all data. To declare a variable in JS, we
use the keyword ‘var’.
To assign value to a variable, we use the assignment operator (=).
Syntax:
var <variable name> = value;
Arrays in JavaScript:
When multiple values are interrelated, we can use arrays.
Create an Array To create an array, we use square brackets [ ].
The items inside an array are separated using commas. We can store as many elements as we want in an
array.
Syntax: var = [‘Item1’, ’Item2’, ‘Item 3’] For example, the following is an array, storing a list of
programming names. var Program_names = [ ‘JavaScript’, ’PHP’, ’HTML’, ’CSS’];
▪ ’Program_names’ is the name of the array.
▪ The items inside the square bracket are the ‘array’ items.
Document.write( ): is a predefined function in java script that displays content on the browser.
OBJECT IN DATABASE :
● An object is a collection of properties, and a property is an association between a name (or
key) and a value.
● An object is a storage container.
Document Object Model (DOM) in JavaScript. JavaScript’s main purpose is to dynamically access and
manipulate HTML elements. For example, clicking a button, hovering over an item, scrolling, etc. DOM is
what allows us to do this. When we load an HTML document onto a browser, the browser converts the
elements into a tree-like structure.
document.getElementsById() - is used to access an HTML element based on its ID.
Logical Operator (AND (&&)) Before defining the else block, understand the use of the Logical
operator. Logical Operators are used when we want to combine 2 or more Boolean expressions and
produce a single Boolean output. Expressions that produce either a TRUE or FALSE value are known
as Boolean Expressions.
T T T
T F F
F T F
F F F
Flex : The flex property sets or returns the length of the item, relative to the rest of the flexible items
inside the same container.
Conditional Statements -
For loop : A "For" Loop is used to repeat a specific block of code a known number of times.
IF Statement : It executes one piece of code if something is true and another piece if it is false.
Syntax
If ( condition )
Take action 1
Else:
Take action 2
= : It helps to assign a value to a variable
== : It use to compare the value of two variables
parseInt() : It is used to convert the value into integer format.
Ecommerce: it is the online selling and buying of goods and services.Example - Amazon,flipkart etc.
Navigation Bar(nav bar) : its a horizontal bar that appears at the top of a website and contains links to
various sections on the website/webpage.
Flexbox : It's a CSS technique that offers an efficient way to lay out and align items without a
container. Layout is automatically adjusted according to the screen type.
Best Seller: A product which sells in a very large quantity.It could be a highest selling product on the
website.
Google Map: It's a web based service that provides detailed information about geographical regions
and sites around the world.