HTML, CSS, Javascript - FWT
HTML, CSS, Javascript - FWT
WEB TECHNOLOGIES
UNIT - 1
HTML introduction:
◻ HTML stands for Hyper Text Markup Language.
◻ It is used to design web pages using a markup
language.
◻ HTML is the combination of Hypertext and
Markup language.
◻ Hypertext defines the link between web pages.
◻ A markup language is used to define the text
document within the tag which defines the
structure of web pages.
◻ This language is used to annotate (make
notes for the computer) text so that a
machine can understand it and
manipulate text accordingly.
◻ Most markup languages (e.g. HTML) are
human-readable.
◻ The language uses tags to define what
manipulation has to be done on the text.
◻ HTML is a markup language used by the
browser to manipulate text, images, and
other content, in order to display it in the
required format.
Tags and elements:
◻ HTML uses predefined tags and
elements which tell the browser how to
properly display the content.
Remember to include closing
tags. If omitted, the browser
applies the effect of the
opening tag until the end of the
page.
HTML structure:
◻ <!DOCTYPE html>: This is the document type
declaration (not technically a tag). It declares a
document as being an HTML document. The doctype
declaration is not case-sensitive.
◻ <html>: This is called the HTML root element. All
other elements are contained within it.
◻ <head>: The head tag contains the “behind the
scenes” elements for a webpage. Elements within the
head aren’t visible on the front-end of a webpage.
◻ <body>: The body tag is used to enclose all the
visible content of a webpage. In other words, the body
content is what the browser will show on the front-end.
Features of HTML
Advantages Disadvantages
elements.
◻ The following example contains: Basic HTML
structure
HTML attributes:
◻ HTML attributes provide additional
information about HTML elements.
◻ All HTML elements can have attributes
◻ Attributes are always specified in the
start tag
◻ Attributes usually come in name/value
pairs like: name="value"
<a href="https://
www.w3schools.com">Visit
W3Schools</a>
HTML formatting:
Formatting elements were designed to display special types
of text:
◻ <b> </b> - Bold text
Italic)
◻ <mark> </mark> - Marked text (marked or highlighted)
document)
◻ <sub> </sub> - Subscript text
◻ Background color:
<h1 style="background-
color:DodgerBlue;">SEC G</h1>
<p style="background-
color:Tomato;">Having FWT
subject</p>
◻ Text color:
<h1 style="color:DodgerBlue;">SEC
G</h1>
<p style="color:Tomato;">Having FWT
subject</p>
◻ Border color:
<h1 style="border:2px solid
Tomato;“>SEC G</h1>
<h1 style="border:2px solid
Violet;">Hello World</h1>
HTML image:
◻ The HTML <img> tag is used to embed an
image in a web page.
◻ The <img> tag has two required
attributes:
src - Specifies the path to the image
alt - Specifies an alternate text for the
image
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
<li>List item 4</li>
</ul>
❑Ordered List tag: It is used to list the
content in a particular order.
<ol>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
<li>List item 4</li>
</ol>
◻ Description Lists: A description list is a
list of terms, with a description of each
term.
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body> </html>
◻ Comment tag: It is used to set the
comment in an HTML document. It is not
visible on the browser.
<!--Comment section-->
◻ Center tag: It is used to set the content
into the center.
<center>SAIKIRAN</center>
□Line break tag: It is used to break the
line.
This is BSH<br>not CSE
HTML Table:
◻ Table tag: A table tag is used to create
a table in an HTML document.
◻ td tag: It defines the standard cell in a
HTML document.
◻ tr tag: It is used to define a row of an
HTML table.
◻ th tag: It defines the header cell in a
table. By default, it set the content with
the bold and center property.
◻ <table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
◻ <table border="4" cellpadding="2"
cellspacing="2" width="50%">
<tr> <td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
◻ Cell padding is the space between the
cell edges and the cell content.
◻ Cell spacing is the space between each
cell.
◻ Column span
specifies the number of columns a cell should
span.
It allows the single table cell to span the width of
more than one cell or column.
It provides the same functionality as “merge
cell” in a spreadsheet program like Excel.
It can be used with <td>and <th> element
while creating an HTML Table.
<td colspan = "value">table
content...</td>
◻ <table>
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>43</td>
</tr>
</table>
◻ Row span
The rowspan attribute in HTML specifies the number
of rows a cell should span.
That is if a row spans two rows, it means it will take
up the space of two rows in that table.
It allows the single table cell to span the height of
more than one cell or row.
It provides the same functionality as “merge cell” in
the spreadsheet program like Excel.
◻ <iframe src="https://
www.javatpoint.com/" height="300" width="400">
</iframe>
◻ <iframe src="https://
www.javatpoint.com/" height="50%" width="70%"
></iframe>
◻ <iframe src="https://
www.javatpoint.com/" style="border:none;"></
iframe>
HTML header:
◻ HTML <header> tag is used as a
container of introductory content or
navigation links. Generally a <header>
element contains one or more heading
elements, logo or icons or author's
information.
◻ You can use several <header> elements in
one document, but a <header> element
cannot be placed within a <footer>,
<address> or another <header> element.
◻ <header>
<h2>ABCOnline.com</h2>
<p> World's no.1 shopping website</
p>
</header>
Marquee tag:
◻ The Marquee HTML tag is a non-
standard HTML element which is used to
scroll a image or text horizontally or
vertically.
◻ In simple words, you can say that it
scrolls the image or text up, down, left or
right automatically.
◻ <marquee width="100%" behavior="scroll" b
gcolor="pink">
This is an example of a scroll marquee...
</marquee>
◻ Slide and alternate
◻ <marquee width="100%" direction="right">
◻ <!DOCTYPE html>
<html>
<head>
<title>Page Layout</title>
</head>
<body>
<!-- Header Section -->
<header style="background-color:DodgerBlue;">
<div class="head1">GeeksforGeeks</div>
<div class="head2">A computer science portal for
geeks</div>
</header>
Navigation bar:
<!-- Menu Navigation Bar -->
<nav class="menu" style="background-
color:Red;" >
<a href="#home">HOME</a>
<a href="#news">NEWS</a>
<a href="#notification">NOTIFICATIONS</a>
<div class="menu-log">
<a href="#login">LOGIN</a>
</div>
</nav>
Body section:
<!-- Body section -->
<main class = "body_sec"
style="background-color:Green;" >
<section id="Content">
<h3>Content section</h3>
</section>
</main>
Footer section:
<!-- Footer Section -->
<footer style="background-
color:Yellow;">Footer
Section</footer>
</body>
</html>
HTML forms:
◻ An HTML form is used to collect user
input. The user input is most often sent
to a server for processing.
◻ The HTML <form> element is used to
create an HTML form for user input:
🞑 <form>
.
form elements
.
</form>
◻ The HTML <input> element is the most used
form element.
◻ An <input> element can be displayed in many
ways, depending on the type attribute.
◻ Types of inputs:
🞑 Text
🞑 Radio
🞑 Check box
🞑 Submit
🞑 Button
🞑 Dropdown box
◻ Checkbox: It is used to define a checkbox
field. The checkbox is shown as a square box
that is ticked when it is activated. It allows the
user to select one or more option among all the
limited choices.
◻ Radio button: It is used to define a Radio
Button. Radio Buttons are used to let the user
select exactly one option from a list of
predefined options. Radio Button input controls
are created by using the “input” element with
a type attribute having value as “radio”.
◻ Text: It is used to define a single-line text
field . The default width of the text field is 20
characters.
◻ Submit: It is used to define a submit button.
It is used to submit all the user value to the
form handler. The Form Handler is a server
page that activates a script for processing all
the input values.
◻ Reset: It is used to defines a reset button.
The reset button is used to reset all the form
values to its initial values.
Drop down box:
◻ The <select> element is used to create
a drop-down list.
◻ The id attribute is needed to associate
the drop-down list with a label.
◻ The <option> tags inside
the <select> element define the
available options in the drop-down list.
◻ Tip: Always add the <label> tag for best
accessibility practices!
◻ date
🞑 The <input type="date"> is used for input fields
that should contain a date.
◻ color
🞑 The <input type="color"> is used for input fields
that should contain a color.
◻ email
🞑 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.
◻ image
🞑 The <input type="image"> defines an
image as a submit button.
🞑 The path to the image is specified in
the src attribute.
◻ password
🞑 <input type="password"> defines
a password field:
◻ file
🞑 The <input type="file"> defines a file-
select field and a "Browse" button for file
uploads.
◻ quantity
🞑 The <input type="number"> defines
a numeric input field.
🞑 You can also set restrictions on what
numbers are accepted.
◻ url
🞑 The <input type="url"> is used for input
fields that should contain a URL address.
◻ time
🞑 The <input type="time"> allows the user
to select a time (no time zone).
◻ telephone
🞑 The <input type="tel"> is used for input
fields that should contain a telephone
number.
◻ Gsearch
🞑 The <input type="search"> is used for
search fields (a search field behaves like a
regular text field).
◻ volume
🞑 The <input type=“volume"> is used to
adjust voulme.
HTML input attributes
◻ value
🞑 The input value attribute specifies an initial
value for an input field:
◻ readonly
🞑 The input readonly attribute specifies that
an input field is read-only.
🞑 A read-only input field cannot be modified
(however, a user can tab to it, highlight it,
and copy the text from it).
◻ disabled
🞑 The input disabled attribute specifies that
an input field should be disabled.
🞑 A disabled input field is unusable and un-
clickable.
◻ size
🞑 The input size attribute specifies the visible
width, in characters, of an input field.
🞑 The default value for size is 20.
◻ maxlength
🞑 The input maxlength attribute specifies the
maximum number of characters allowed in
an input field.
◻ min and max
🞑 The input min and max attributes specify the
minimum and maximum values for an input
field.
🞑 The min and max attributes work with the
following input types: number, range, date,
datetime-local, month, time and week.
◻ pattern
🞑 The input pattern attribute specifies a regular
expression that the input field's value is checked
against, when the form is submitted.
🞑 The pattern attribute works with the following input
types: text, date, search, url, tel, email, and password.
◻ required
🞑 The input required attribute specifies that an input
field must be filled out before submitting the form.
🞑 The required attribute works with the following input
types: text, search, url, tel, email, password, date
pickers, number, checkbox, radio, and file.
◻ step
🞑 The input step attribute specifies the legal
number intervals for an input field.
🞑 Example: if step="3", legal numbers could
be -3, 0, 3, 6, etc.
◻ height and width
🞑 The input height and width attributes
specify the height and width of an <input
type="image"> element.
◻ autocomplete
🞑 The input autocomplete attribute specifies
whether a form or an input field should
have autocomplete on or off.
🞑 Autocomplete allows the browser to predict
the value. When a user starts to type in a
field, the browser should display options to
fill in the field, based on earlier typed
values.
CSS
HTML CSS
◻ <style>
body {
background-image: url("paper.gif");
}
</style>
◻ By default, the background-image property
repeats an image both horizontally and
vertically.
◻ Showing the background image only once is
also specified by the background-
repeat property:
◻ The background-position property is used to
specify the position of the background image.
🞑 left top, left center, left bottom, right top, right
center, right bottom, center top, center center,
center bottom
◻ The background-attachment property
specifies whether the background image
should scroll or be fixed (will not scroll with
the rest of the page):
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
}
🞑 fixed or scroll.
Multiple background images:
◻ <style>
body {
background-image:
url("img_tree.gif"), url("paper.gif");
background-repeat: no-repeat,
repeat;
background-color: #cccccc;
}
</style>
CSS margins:
◻ CSS has properties for specifying the
margin for each side of an element:
🞑 margin-top
🞑 margin-right
🞑 margin-bottom
🞑 margin-left
◻ <style>
div.a{
margin-top: 300px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
background-color: lightblue;
}
</style>
CSS lists:
◻ The CSS list properties allow you to:
🞑 Set different list item markers for ordered
lists
🞑 Set different list item markers for unordered
lists
🞑 Set an image as the list item marker
🞑 Add background colors to lists and list items
◻ Two types of lists:
🞑 Ordered list
🞑 Unordered list
◻ The list-style-type property specifies the type of list
item marker.
◻ The list-style-image property specifies an image as
the list item marker.
◻ The list-style-position property specifies the
position of the list-item markers (bullet points).
🞑 "list-style-position: outside;" means that the bullet
points will be outside the list item. The start of each
line of a list item will be aligned vertically.
🞑 list-style-position: inside;" means that the bullet points
will be inside the list item. As it is part of the list item,
it will be part of the text and push the text at the start:
CSS Tables:
◻ To specify table borders in CSS, use
the border property.
◻ The example specifies a solid border for
<table>, <th> and <td> elements:
table, th, td {
border: 1px solid;
}
◻ table {
width: 100%;
}
Adjusting height
◻ table {
width: 100%;
}
th {
height: 70px;
}
Table alignment:
◻ td {
text-align: center;
}
Vertical alignment:
◻ The vertical-align property sets the vertical
◻ 1.css
<html>
<head>
<link rel="stylesheet" href=“1.css"/>
</head> <body>
<p>Hello World!</p>
<p>These paragraphs are styled with
CSS.</p>
</body>
</html>
CSS layout:
CSS links:
◻ The four links states are:
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user grags mouse
over it
a:active - a link the moment it is clicked
<html>
<head>
<style>
/* unvisited link */
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: hotpink;
}
/* selected link */
a:active {
color: blue;
}
</style>
</head>
<body>
<a href="default.asp" >This is a
link</a>
</body>
</html>
div and span
◻ The div tag is a block level HTML
element. It is used
to divide or section other HTML
elements into groups.
<html>
<head> <style>
div.sample
{width:150px;background:#FF0002;border:2px
dotted black;padding:7px;}
div.sample ul {color:green;}
</style> </head>
<body>
<div class="sample"> <p>Samplep> <ul>
<li>Home</li> <li>Aboutus</li>
<li>Contactus</li> </ul> </div>
</body> </html>
◻ span tag is used for some hexadecimal
codes like six-digit codes that represent
the amount of color is also specified the
percentage values.
<html> <body>
<p>Sample<span
style="color:#FF0002;">
<i>Welcome</span></i>
Welcome My Domain</p>
<p><span style="color:#8865ff;">
Welcome to My Domain</span></p>
</body> </html>
JAVA SCRIPT
Java script:
◻ Java Script is one popular scripting language
over internet. Scripting means a small sneak
(piece). It is always independent on other
languages.
◻ JavaScript is most commonly used as a client
side scripting language. This means that
JavaScript code is written into an HTML page.
When a user requests an HTML page with
JavaScript in it, the script is sent to the
browser and it's up to the browser to do
something with it.
Why we Use JavaScript?
◻ Using HTML we can only design a web
page but you can not run any logic on
web browser like addition of two
numbers, check any condition, looping
statements (for, while), decision making
statement (if-else) at client side. All
these are not possible using HTML So for
perform all these task at client side you
need to use JavaScript.
Features:
Placement:
◻ In head
<html>
<head>
<script>
Code here
</script>
</head>
<body>
</body>
</html>
In body
◻ <html>
<head>
</head>
<body>
<script>
Code here
</script>
</body>
</html>
Both in head and body
◻ <html>
<head>
<script>
Script code here
</script>
</head>
<body>
<script>
Script code here
</script>
</body>
</html>
External file
◻ <html> <head>
<script src = "filename.js" >
</script>
</head>
<body> ....... </body>
</html>
Linking of an external file with
filename.js using the src attribute.
◻ function sayHello()
{
alert("Hello World")
}
( external file with file name
filename.js in the previous slide)
Javascript outputs:
◻ Writing into an HTML element,
using innerHTML
◻ Writing into the HTML output
using document.write()
◻ Writing into an alert box,
using window.alert()
◻ Writing into the browser console,
using console.log()
Method 1:
◻ To access an HTML element, JavaScript
can use
the document.getElementById(id) m
ethod.
◻ The id attribute defines the HTML
element.
◻ <!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>
</body>
</html>
Method 2:
◻ For testing purposes, it is convenient to
use document.write()
◻ <!DOCTYPE html>
<html>
<body>
<script>
document.write(5 + 6);
</script>
</body>
</html>
Method 3:
You can use an alert box to display data
◻ <!DOCTYPE html>
<html>
<body>
<script>
window.alert(5 + 6);
</script>
</body>
</html>
Method 4:
◻ You can skip the window keyword.
◻ In JavaScript, the window object is the
global scope object. This means that
variables, properties, and methods by
default belong to the window object. This
also means that specifying
the window keyword is optional
◻ <!DOCTYPE html>
<html>
<body>
<script>
alert(5 + 6);
</script>
</body>
</html>
Method 5
◻ For debugging purposes, you can call the
console.log() method in the browser to
display data.
<html>
<body>
<h2>Activate Debugging</h2>
<p>F12 on your keyboard will activate
debugging.</p>
<p>Then select "Console" in the debugger
menu.</p>
<p>Then click Run again.</p>
<script>
console.log(5 + 6);
</script> </body> </html>
Enabling using web browser
◻ Activate JavaScript in Google Chrome
Open Chrome on your computer.
Click Settings.
Click Security and Privacy.
Click Site settings.
Click JavaScript.
Select Sites can use Javascript.
◻ https://www.enable-javascript.com/
Java Script Variables:
◻ Variables are containers for storing data
(storing data values).
◻ 4 Ways to Declare a JavaScript Variable:
🞑 Using var
🞑 Using let
🞑 Using const
🞑 Using nothing
◻ Variables defined with let cannot be
Redeclared.
const PI = 3.141592653589793;
PI = 3.14; // This will give an error
PI = PI + 10; // This will also give an
error
◻ If you want a general rule: always
declare variables with const.
<script>
let text =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.write(text.length);
</script>
</body>
</html>
JavaScript Strings as Objects:
<html>
<body>
<script>
function myFunction(p1, p2) {
return p1 * p2;
}
document.write(myFunction(4, 3));
</script>
</body>
</html>
Extracting String Parts:
◻ There are 3 methods for extracting a
part of a string:
slice(start, end)
substring(start, end)
substr(start, length)
<html>
<body>
<script>
let text = "Apple,Banana,Kiwi";
let part = text.slice(7,13);
document.write(part);
</script>
</body>
</html>
<html>
<body>
<script>
let text = "Apple,Banana,Kiwi";
let part = text.slice(7);
document.write(part);
</script>
</body>
</html>
<html>
<body>
<script>
let text = "Apple, Banana, Kiwi";
let part = text.slice(-12);
document.write(part);
</script>
</body>
</html>
<html>
<body>
<script>
let text = "Apple, Banana, Kiwi";
let part = text.slice(-12,-6);
document.write(part);
</script>
</body>
</html>
Replacing String Content:
let text = "Please visit Microsoft";
let newText =
text.replace("Microsoft", "W3School
s");
text =
text.replaceAll("cats","dogs");
◻ let text1 = "Hello World!";
let text2 = text1.toUpperCase();
<script>
let text1 = "Hello";
let text2 = "World!";
let text3 = text1.concat(" ",text2);
document.write(text3);
</script>
</body>
</html>
Adding JavaScript Strings
◻ let text1 = "John";
let text2 = "Doe";
let text3 = text1 + " " + text2;
<script>
const cars = ["Saab", "Volvo", "BMW"];
document.write(cars);
</script>
</body>
</html>
Assigning values using index number:
<html>
<body>
<h2>JavaScript Arrays</h2>
<script>
const cars = [];
cars[0]= "Saab";
cars[1]= "Volvo";
cars[2]= "BMW";
document.write(cars);
</script>
</body>
</html>
Using the JavaScript Keyword new:
◻ <html>
<body>
<script>
const cars = new Array("Saab", "Volvo",
"BMW");
document.write(cars);
</script>
</body>
</html>
Accessing Array Elements:
<html>
<body>
<script>
const cars = ["Saab", "Volvo", "BMW"];
document.write(cars[0]);
</script>
</body>
</html>
Changing an Array Element:
<html>
<body>
<script>
const cars = ["Saab", "Volvo", "BMW"];
cars[0] = "Opel";
document.write(cars);
</script>
</body>
</html>
Arrays are Objects:
◻ Objects use names to access its "members".
<html>
<body>
<script>
const person = {firstName:"John", lastName:"Doe",
age:46};
document.write(person.firstName);
</script>
</body>
</html>
Array Properties and Methods:
<html>
<body>
<script>
const fruits = ["Banana", "Orange", "Apple",
"Mango"];
document.write(fruits.length);
</script>
</body>
</html>
Accessing the Last Array Element:
<html>
<body>
<script>
var fruits = ["Banana", "Orange", "Apple",
"Mango"];
document.write(fruits[fruits.length-1]);
</script>
</body>
</html>
Looping Array Elements:
<html>
<body>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
let fLen = fruits.length;
let text = "<ul>";
for (let i = 0; i < fLen; i++) {
text += "<li>" + fruits[i] + "</li>";
}
text += "</ul>";
document.write(text);
</script>
</body>
</html>
Types of JS arrays:
◻ One dimensional
◻ Multi-dimensional
🞑 A multidimensional array is accessed in the
same way as a one-dimensional array. The
only difference is that we have to use two
or more indices to access the elements of
the multidimensional array in javascript.
<html><body>
<script>
let x=[
[20,10,10],[10,10,10],[30,30,30]
];
document.write(x[2][2]);
</script>
</body></head>
JavaScript Scope
◻ Scope determines the accessibility
(visibility) of variables.
<button
onclick="document.write(Date())">
The time is?</button>
</body>
</html>
Adding two numbers:
<html><body>
<h2>JavaScript HTML Events</h2>
<button onclick="this.innerHTML=num3">Sum
is</button>
<script>
let num1 = prompt("Please enter your num1");
let num2 = prompt("Please enter your num2");
let num3 = parseInt(num1) + parseInt(num2);
</script>
</body></html>
DOM HTML
◻ The HTML DOM is an Object Model for
HTML. It defines:
🞑 HTML elements as objects
🞑 Properties for all HTML elements
🞑 Methods for all HTML elements
🞑 Events for all HTML elements
◻ The HTML DOM is an API (Programming
Interface) for JavaScript:
🞑 JavaScript can add/change/remove HTML
elements
🞑 JavaScript can add/change/remove HTML
attributes
🞑 JavaScript can add/change/remove CSS styles
🞑 JavaScript can react to HTML events
🞑 JavaScript can add/change/remove HTML
events
Tree structure of DOM HTML model:
◻ When you want to access HTML elements with
JavaScript, you have to find the elements first.
<body>
<p id="intro">Finding HTML Elements by Id</p>
<p id="demo"></p>
<script>
const element =
document.getElementById("intro");
document.getElementById("demo").innerHTML =
"The text from the intro paragraph is: " +
element.innerHTML;
</script>
</body>
Finding HTML Element by tag name
<body>
<p>Finding HTML Elements by Tag Name.</p>
<p>This example demonstrates .</p>
<p id="demo"></p>
<script>
const element =
document.getElementsByTagName("p");
document.getElementById("demo").innerHTML = 'The
text in first paragraph (index 0) is: ' +
element[0].innerHTML;
</script>
</body>
Finding HTML Elements by Class
Name
<body>
<p class="intro">Hello World!</p>
<p class="intro">This example demonstrates the
method.</p>
<p id="demo"></p>
<script>
const x = document.getElementsByClassName("intro");
document.getElementById("demo").innerHTML =
'The first paragraph (index 0) with class="intro" is:
' + x[0].innerHTML;
</script> </body>
Finding HTML Elements by CSS
Selectors
<body>
<p class="intro">Hello World!.</p>
<p class="intro">This example demonstrates the
<b>querySelectorAll</b> method.</p>
<p id="demo"></p>
<script>
const x = document.querySelectorAll("p.intro");
document.getElementById("demo").innerHTML =
'The first paragraph (index 0) with class="intro"
is: ' + x[0].innerHTML;
</script></body>
DHTML
◻ DHTML stands for Dynamic Hypertext
Markup language i.e., Dynamic
HTML.
◻ Dynamic HTML is not a markup or
programming language but it is a term
that combines the features of various
web development technologies for
creating the web pages dynamic and
interactive.
Components of Dynamic HTML
◻ HTML 4.0
◻ CSS
◻ JavaScript
◻ DOM.
◻ HTML 4.0
HTML is a client-side markup language, which is
a core component of the DHTML. It defines the
structure of a web page with various defined
basic elements or tags.
◻ CSS
CSS stands for Cascading Style Sheet, which
allows the web users or developers for
controlling the style and layout of the HTML
elements on the web pages.
◻ JavaScript
JavaScript is a scripting language which is done on a
client-side. The various browser supports JavaScript
technology. DHTML uses the JavaScript technology for
accessing, controlling, and manipulating the HTML
elements. The statements in JavaScript are the
commands which tell the browser for performing an
action.
◻ DOM
Hypertext pre-
processor
Introduction:
◻ PHP is an acronym for "PHP: Hypertext
Preprocessor"
◻ PHP is a widely-used, open source
scripting language
◻ PHP scripts are executed on the server
◻ PHP is free to download and use
What is a PHP File?
◻ PHP files can contain text, HTML, CSS,
JavaScript, and PHP code
◻ PHP code is executed on the server, and
the result is returned to the browser as
plain HTML
◻ PHP files have extension ".php"
Why PHP ?
◻ PHP runs on various platforms (Windows,
Linux, Unix, Mac OS X, etc.)
◻ PHP is compatible with almost all servers
used today (Apache, IIS, etc.)
◻ PHP supports a wide range of databases
◻ PHP is easy to learn and runs efficiently
on the server side
PHP Syntax
◻ <!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
Declaring variables:
◻ <?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
echo $txt;
echo "<br>";
echo $x;
echo "<br>";
echo $y;
?>
Decisions :
◻ <?php
$t = 25;
switch ($favcolor) {
case "red":
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "Your favorite color is neither red, blue, nor
green!";
}
?>
Loops:
◻ while - loops through a block of code as
long as the specified condition is true
◻ do...while - loops through a block of
code once, and then repeats the loop as
long as the specified condition is true
◻ for - loops through a block of code a
specified number of times
◻ foreach - loops through a block of code
for each element in an array
◻ The foreach loop works only on arrays, and is
used to loop through each key/value pair in an
array.
◻ <?php
$colors
= array("red", "green", "blue", "yellow");
<?php
function writeMsg() {
echo "Hello world!";
}
writeMsg();
?>
</body>
</html>
Functions with arguments:
◻ <?php
function familyName($fname, $year) {
echo "$fname Refsnes. Born in $year
<br>";
}
familyName("Hege", "1975");
familyName("Stale", "1978");
familyName("Kai Jim", "1983");
?>
Strings:
◻ The PHP strlen() function returns the length
of a string.
🞑 <?php
echo strlen("Hello world!"); // outputs 12
?>
◻ The PHP str_word_count() function counts
the number of words in a string.
🞑 <?php
echo str_word_count("Hello world!"); //
outputs 2
?>
◻ The PHP strrev() function reverses a string.
🞑 <?php
echo strrev("Hello world!"); // outputs !
dlrow olleH
?>
◻ The PHP str_replace() function replaces some
characters with some other characters in a
string.
🞑 <?php
echo str_replace("world", "Dolly", "Hello
world!"); // outputs Hello Dolly!
?>
Arrays:
◻ In PHP, there are three types of arrays:
Indexed arrays - Arrays with a numeric
index
Associative arrays - Arrays with named
keys
Multidimensional arrays - Arrays
containing one or more arrays
Indexed arrays:
◻ $cars = array("Volvo", "BMW", "Toyota");
◻ $cars[0] = "Volvo";
$cars[1] = "BMW";
$cars[2] = "Toyota";
◻ <?php
$cars
= array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " .
$cars[1] . " and " . $cars[2] . ".";
?>
Loop Through an Indexed Array
<?php
$cars = array("Volvo", "BMW",
"Toyota");
$arrlength = count($cars);
for($x = 0; $x < $arrlength; $x++) {
echo $cars[$x];
echo "<br>";
}
?>
Associative array:
◻ Associative arrays are arrays that use
named keys that you assign to them.
<?php
$age
= array("Peter"=>"35", "Ben"=>"37
", "Joe"=>"43");
echo "Peter is " . $age['Peter'] . "
years old.";
?>
Loop Through an Associative Array
<?php
$age = array("Peter"=>"35",
"Ben"=>"37", "Joe"=>"43");
foreach($age as $x => $x_value) {
echo "Key=" . $x . ", Value=" .
$x_value;
echo "<br>";
}
?>
Multidimensional array:
◻ <?php
$cars = array (
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
<?php
$cars = array
(array("Volvo",22,18),array("BMW",15,13),array("Saa
b",5,2),
array("Land Rover",17,15) );
for ($row = 0; $row < 4; $row++) {
echo "<p><b>Row number $row</b></p>";
echo "<ul>";
for ($col = 0; $col < 3; $col++) {
echo "<li>".$cars[$row][$col]."</li>";
}
echo "</ul>";
}
DBMS
Database management system
Data:
◻ Data is a collection of a distinct small
unit of information. It can be used in a
variety of forms like text, numbers,
media, bytes, etc. it can be stored in
pieces of paper or electronic memory,
etc.
Database:
◻ A database is an organized collection of data,
so that it can be easily accessed and managed.
◻ We can organize data into tables, rows,
columns, and index it to make it easier to find
relevant information.
◻ The main purpose of the database is to
operate a large amount of information by
storing, retrieving, and managing data.
◻ There are many databases available like
MySQL, Sybase, Oracle, MongoDB, Informix,
PostgreSQL, SQL Server, etc.
What is RDBMS?
◻ RDBMS stands for Relational Database
Management System.
◻ All modern database management
systems like SQL, MS SQL Server, IBM
DB2, ORACLE, My-SQL, and Microsoft
Access are based on RDBMS.
How it works.....
◻ Data is represented in terms of tuples
(rows) in RDBMS.
◻ A relational database is the most
commonly used database. It contains
several tables, and each table has its
primary key.
◻ Due to a collection of an organized set of
tables, data can be accessed easily in
RDBMS.
What is table/Relation?
◻ Everything in a relational database is
stored in the form of relations. The
RDBMS database uses tables to store
data. A table is a collection of related
data entries and contains rows and
columns to store data.
Properties of a Relation:
◻ Each relation has a unique name by which it is
identified in the database.
◻ Relation does not contain duplicate tuples.
◻ The tuples of a relation have no specific order.
◻ All attributes in a relation are atomic, i.e., each
cell of a relation contains exactly one value.
◻ A table is the simplest example of data stored
in RDBMS.
What is a row or record?
◻ A row of a table is also called a record or tuple. It
contains the specific information of each entry in
the table. It is a horizontal entity in the table.
Properties of a row:
◻ No two tuples are identical to each other in all
their entries.
◻ All tuples of the relation have the same format