<!DOCTYPE html>
<
html
>
<
head
>
<
title
>Using JavaScript</
title
>
</
head
>
<
style
>
body {
margin: 0;
font-family: Arial, sans-serif;
}
header,
footer {
background-color: #333;
color: #fff;
padding: 10px 0;
text-align: center;
}
nav ul {
list-style: none;
padding: 0;
}
nav li {
display: inline-block;
margin-right: 20px;
}
nav a {
text-decoration: none;
color: #fff;
}
nav a:hover {
color: red;
}
main {
padding: 20px;
}
section {
background-color: #e6e6e6;
padding: 20px;
border-radius: 5px;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
}
footer {
position: fixed;
bottom: 0;
width: 100%;
}
.sticky {
position: sticky;
top: 0;
z-index: 100;
}
p {
text-align: center;
}
</
style
>
<
body
>
<
header
class
=
"sticky"
>
<
nav
>
<
ul
>
<
li
><
a
href
=
"#html"
>HTML</
a
></
li
>
<
li
><
a
href
=
"#css"
>CSS</
a
></
li
>
<
li
><
a
href
=
"#Js"
>JavaScript</
a
></
li
>
</
ul
>
</
nav
>
</
header
>
<
main
>
<
section
>
<
h1
style
=
"color: green; text-align: center;"
id
=
"html"
>
HTML
</
h1
>
<
p
>
HTML stands for HyperText Markup Language.
It is used to design the web pages. With
the help of HTML, you can create a complete
website structure. HTML is the combination
of Hypertext and Markup language. Hypertext
defines the link between the web pages and
markup language defines the text document
within the tag that define the structure
of web pages.
</
p
>
<
h1
style
=
"color: green; text-align: center;"
id
=
"css"
>
CSS
</
h1
>
<
p
>
CSS (Cascading Style Sheets) is used to
styles web pages. Cascading Style Sheets
are fondly referred to as CSS. The reason
for using this is to simplify the process
of making web pages presentable. It allows
you to apply styles on web pages. More
importantly, it enables you to do this
independently of the HTML that makes up
each web page.
</
p
>
<
h1
style
=
"color: green; text-align: center;"
id
=
"Js"
>
JavaScript
</
h1
>
<
p
>
JavaScript is a lightweight, cross-platform,
single-threaded, and interpreted compiled
programming language. It is also known as
the scripting language for webpages. It is
well-known for the development of web pages,
and many non-browser environments also use it.
JavaScript is a weakly typed language (
dynamically typed). JavaScript can be used
for Client-side developments as well as
Server-side developments. JavaScript is both
an imperative and declarative type of language.
JavaScript contains a standard library of
objects, like Array, Date, and Math, and a
core set of language elements like operators,
control structures, and statements.
</
p
>
</
section
>
</
main
>
<
footer
class
=
"sticky"
>
<
p
>© 2023 Geeksforgeeks. All rights reserved.</
p
>
</
footer
>
<
script
> const header = document.querySelector('header');
const footer = document.querySelector('footer');
const headerOffset = header.offsetTop;
const footerOffset = footer.offsetTop;
function handleScroll() {
if (window.pageYOffset >= headerOffset) {
header.classList.add('sticky');
} else {
header.classList.remove('sticky');
}
if (window.pageYOffset >= footerOffset - window.innerHeight) {
footer.classList.add('sticky');
} else {
footer.classList.remove('sticky');
}
}
window.addEventListener('scroll', handleScroll);
</
script
>
</
body
>
</
html
>