Programs in HTML and CSS
Programs in HTML and CSS
Bold text Italic text Underlined text Strong text Super script Sub script
<ul type="circle">
<li>Peacock</li>
<li>Parrot</li>
<li>Sparrow</li>
<li>Swan</li>
<li>Pigeon</li>
</ul>
<ul type="square">
<li>Peacock</li>
<li>Parrot</li>
<li>Sparrow</li>
<li>Swan</li>
<li>Pigeon</li>
</ul>
</body>
</html>
Output :
Unordered list
Peacock
Parrot
Sparrow
Swan
Pigeon
o Peacock
o Parrot
o Sparrow
o Swan
o Pigeon
Peacock
Parrot
Sparrow
Swan
Pigeon
Ordered list
<ol>
<li>Car</li>
<li>Bicycle</li>
<li>Aeroplane</li>
<li>Bus</li>
</ol>
<ol type="a">
<li>Car</li>
<li>Bicycle</li>
<li>Aeroplane</li>
<li>Bus</li>
</ol>
<ol type="A">
<li>Car</li>
<li>Bicycle</li>
<li>Aeroplane</li>
<li>Bus</li>
</ol>
<ol type="i">
<li>Car</li>
<li>Bicycle</li>
<li>Aeroplane</li>
<li>Bus</li>
</ol>
<ol type="I">
<li>Car</li>
<li>Bicycle</li>
<li>Aeroplane</li>
<li>Bus</li>
</ol>
<ol start="6">
<li>Car</li>
<li>Bicycle</li>
<li>Aeroplane</li>
<li>Bus</li>
</ol>
</body>
</html>
Output :
Ordered list
1. Car
2. Bicycle
3. Aeroplane
4. Bus
a. Car
b. Bicycle
c. Aeroplane
d. Bus
A. Car
B. Bicycle
C. Aeroplane
D. Bus
i. Car
ii. Bicycle
iii. Aeroplane
iv. Bus
I. Car
II. Bicycle
III. Aeroplane
IV. Bus
6. Car
7. Bicycle
8. Aeroplane
9. Bus
Invoice
Sno Item Price
1 Apple Rs. 20
2 Mango Rs. 15
3 Banana Rs. 3
<html>
<head>
<title>Linking Image object</title>
</head>
<body>
Tim Berners Lee
<img src="TimBernersLee.jpg" width="150" />
</body>
</html>
Output :
<html>
<head>
<title>Marquee tag</title>
</head>
<body>
<marquee direction="right">Scrolling right</marquee>
<marquee direction="left">Scrolling left</marquee>
<marquee direction="down">Scrolling down</marquee>
<marquee direction="up">Scrolling up</marquee>
<marquee behavior="slide"><img src="2.jpg" width="100"></marquee>
<marquee behavior="alternate" scrollamount="20"><img src="4.jpg" width="100"></marquee>
</body>
</html>
<html>
<head>
<title>Basic layout of web page</title>
</head>
<body>
<table border="1">
<tr>
<td colspan="2" width="200" height="50" align="center">Header</td>
<tr>
<td colspan="2" width="200" height="15" align="center">Menu items</td>
</tr>
<tr>
<td width="50" height="200">Left<br />Navigation</td>
<td width="150" height="200">Main Content Area</td>
</tr>
<tr>
<td colspan="2" width="200" height="15" align="center">Footer</td>
</tr>
</table>
</body>
</html>
Output :
Header
Menu items
Left
Main Content Area
Navigation
Footer
CSS
11. Creating Horizontal menu using CSS.
style.css
#menubar{
width:680px;
height:40px;
background-color:#333;
}
#menubar ul{
list-style-type:none;
padding-left:0;
}
#menubar ul li{
display:inline;
}
#menubar ul li a{
width:136px;
color:#FFF;
text-decoration:none;
float:left;
text-align:center;
line-height:40px;
}
#menubar ul li a:hover{
color:#39F;
background-color:#000;
}
css_menu.html
<html>
<body>
<div id="menubar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Features</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</body>
</html>
style.css
*{
margin:0;
}
body{
background-color:#09F;
}
#wrapper{
width:980px;
height:768px;
background-color:#CC9;
margin-left:auto;
margin-right:auto;
}
#banner{
width:960px;
height:130px;
background-color:#630;
color:#FFF;
font-size:36px;
padding:20px 0 0 20px;
}
#menubar{
width:980px;
height:40px;
background-color:#333;
}
#menubar ul{
list-style-type:none;
padding-left:0;
}
#menubar ul li{
display:inline;
}
#menubar ul li a{
width:196px;
color:#FFF;
text-decoration:none;
float:left;
text-align:center;
line-height:40px;
}
#menubar ul li a:hover{
color:#39F;
background-color:#000;
}
#container{
width:980px;
height:538px;
background-color:#FC9;
}
#footer{
width:980px;
height:40px;
background-color:#333;
color:#fff;
text-align:center;
line-height:40px;
}
#content{
width:740px;
height:528px;
background-color:#FFF;
float:left;
margin:5px;
}
#sidebar{
width:225px;
height:528px;
background-color:#660;
float:left;
margin:5px 5px 5px 0;
}
layout1.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="wrapper">
<div id="banner">
MyCollege.com
</div>
<div id="menubar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Features</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div id="container">
<div id="content">
</div>
<div id="sidebar">
</div>
</div>
<div id="footer">
© 2015
</div>
</div>
</body>
</html>
Output :
style.css
#box1{
width:200px;
height:200px;
background-color:#09F;
float:left;
margin-right:20px;
}
#box2{
width:200px;
height:200px;
background-color:#F96;
float:left;
margin-right:20px;
}
#box3{
width:200px;
height:200px;
background-color:#6C6;
float:left;
margin-right:20px;
}
boxmodel.html
<body>
<div id="box1"></div>
<div id="box2"></div>
<div id="box3"></div>
</body>
Output :
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<style>
.rnd{
border-radius:10px;
text-align:center;
border-color:#63C;
height:30px;
width:200px;
}
#form1{
width:250px;
height:200px;
background-color:#00CCFF;
box-shadow:10px 10px 1px #999999;
text-align:center;
padding-top:20px;
border-radius:10px;
}
</style>
</head>
<body>
<div id="form1">
<input type="text" class="rnd" placeholder="User name" />
</div>
</body>
</html>
Output :
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<style>
#box{
text-align:center;
text-shadow:5px 5px 3px #999999;
font-size:36px;
font-family:"Times New Roman", Times, serif;
}
</style>
</head>
<body>
<div id="box">
Welcome to CSS3
</div>
</body>
</html>
Output :
16. CSS3 scale() example.
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<style>
#box{
width:100px;
height:100px;
font-size:18px;
background-color:#0CF;
border-radius:5px;
box-shadow:10px 10px 2px #999999;
text-align:center;
padding-top:20px;
text-shadow:2px 2px 2px #666666;
}
#box:hover{
transform:scale(2,1.5);
-webkit-transform:scale(2,1.5);
-ms-transform:scale(2,1.5);
}
</style>
</head>
<body>
<div id="box">
Mouse over me
</div>
</body>
</html>
Output:
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<style>
#box{
width:200px;
height:100px;
font-size:26px;
background-color:#0CF;
border-radius:5px;
box-shadow:10px 10px 2px #999999;
text-align:center;
padding-top:20px;
text-shadow:5px 5px 2px #666666;
transform:skew(130deg,10deg);
-webkit-transform:skew(130deg,10deg);
-ms-transform:skew(130deg,10deg);
position:relative;
top:50px;
left:200px
}
</style>
</head>
<body>
<div id="box">
Welcome to CSS3
</div>
</body>
</html>
Output :
.
18. CSS3 transition example.
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<style>
#box{
width:100px;
height:100px;
font-size:20px;
background-color:#0CF;
border-radius:5px;
box-shadow:10px 10px 2px #999999;
text-align:center;
padding-top:20px;
text-shadow:5px 5px 2px #666666;
transition:width 2s, height 2s, transform 2s;
-webkit-transition:width 2s, height 2s, left 2s, -webkit-transform 2s;
position:relative;
top:50px;
left:100px;
}
#box:hover{
width:150px;
height:150px;
left:400px;
transform:rotate(360deg);
-webkit-transform:rotate(360deg);
}
</style>
</head>
<body>
<div id="box">
Welcome to CSS3
</div>
</body>
</html>
Output :
<body>
<div id="box">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of
type and scrambled it to make a type specimen book. It has survived not only five centuries, but also
the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the
1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
It is a long established fact that a reader will be distracted by the readable content of a page when
looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution
of letters, as opposed to using 'Content here, content here', making it look like readable English.
Many desktop publishing packages and web page editors now use Lorem Ipsum as their default
model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various
versions have evolved over the years, sometimes by accident, sometimes on purpose (injected
humour and the like).
</div>
</body>
</html>
Output :
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<style>
#box{
width:150px;
height:100px;
font-size:26px;
background-color:#0CF;
border-radius:5px;
box-shadow:10px 10px 2px #999999;
text-align:center;
padding-top:20px;
text-shadow:2px 2px 2px #666666;
transform:rotateY(180deg);
-webkit-transform:rotateY(180deg);
-ms-transform:rotateY(180deg);
position:relative;
top:50px;
left:200px;
}
</style>
</head>
<body>
<div id="box">
3D rotation
</div>
</body>
</html>
Output :
21. WEB PAGE PHOTO ALBUM
styles.css
/* styles.css */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.photo-album {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
.gallery {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.photo {
margin: 10px;
text-align: center;
}
.photo img {
width: 100%;
max-width: 300px;
height: auto;
border-radius: 8px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
album.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Photo Album</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="photo-album">
<h1>My Photo Album</h1>
<div class="gallery">
<div class="photo">
<img src="logo.jpg" alt="Description of Image 1">
<p>Caption for Image 1</p>
</div>
<div class="photo">
<img src="pic2.jpg" alt="Description of Image 2">
<p>Caption for Image 2</p>
</div>
<div class="photo">
<img src="pic1.jpg" alt="Description of Image 3">
<p>Caption for Image 3</p>
</div>
</div>
</div>
</body>
</html>
/* styles.css */
.my-button {
background-color: #007bff; /* Primary color */
color: white; /* Text color */
border: none;
border-radius: 4px; /* Rounded corners */
padding: 10px 20px; /* Vertical and horizontal padding */
font-size: 16px; /* Font size */
cursor: pointer; /* Pointer cursor on hover */
transition: background-color 0.3s ease, transform 0.2s ease; /* Smooth transitions */
}
.my-button:hover {
background-color: #0056b3; /* Darker shade on hover */
}
.my-button:active {
transform: scale(0.98); /* Slight shrink effect on click */
}
.my-button:focus {
outline: none; /* Remove default focus outline */
}
button.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Button Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<button class="my-button">Click Me!</button>
</div>
</body>
</html>
styles.css
/* styles.css */
body {
margin: 0;
font-family: Arial, sans-serif;
}
.banner {
background: url('pic1.jpg') no-repeat center center/cover; /* Background image */
color: white; /* Text color */
text-align: center;
padding: 100px 20px; /* Vertical and horizontal padding */
position: relative;
}
.banner-content {
position: relative;
z-index: 2; /* Ensure content is above any overlay */
}
.banner h1 {
font-size: 3em; /* Font size for the title */
margin: 0;
padding: 0;
}
.banner p {
font-size: 1.5em; /* Font size for the tagline */
margin: 10px 0;
}
.btn {
display: inline-block;
background-color: #007bff; /* Button background color */
color: white; /* Button text color */
padding: 10px 20px; /* Vertical and horizontal padding */
font-size: 1em; /* Font size */
text-decoration: none; /* Remove underline */
border-radius: 5px; /* Rounded corners */
transition: background-color 0.3s ease, transform 0.2s ease; /* Smooth transitions */
}
.btn:hover {
background-color: #0056b3; /* Darker shade on hover */
}
.btn:active {
transform: scale(0.98); /* Slight shrink effect on click */
}
banner.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>College Banner</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header class="banner">
<div class="banner-content">
<h1>Shasun College</h1>
<p>Your Path to Excellence</p>
<a href="#learn-more" class="btn">Learn More</a>
</div>
</header>
</body>
</html>