HTML and Css Notes For Beginners
HTML and Css Notes For Beginners
+918630879950
md.jakirmadh@gmail.com
What is HTML 5:
HTML stands for Hypertext Markup Language . It was developed by Tim Berner Lee in 1990. It
is a language that defines the structure and content of web pages. HTML is used to create
dynamic and static web pages and is the foundation of the World Wide Web.
• HTML tells web browsers how to display text, images, and other content on a web page
• HTML provides the basic framework for displaying multimedia and text on the internet
• HTML uses markup tags to structure the content of a web page
• HTML uses markup tags to define elements such as headings, paragraphs, links, and
images
• HTML tags are enclosed by less than < and > greater than and it called tags.
• HTML tags can include attributes, which provide more information about the element
• HTML tags can be used with other technologies, such as CSS and JavaScript, to describe
the appearance and behavior of a web page
Hyper Text: It is a link text if you click any link then transfer particular place.
Markup: It means make up of selected tag and give attractive style there are some types of tag
as following.
Types of Tag:
There are two type tag as following.
1. Container Tag: It have open and close tag and written content between tag
Syntax:
Close Tag
<TagName>Content</TagName>
Open Tag
Example:
<h1>Content</h1>
<p>Paragraph</p> etc.
2. Empty Tag: This type tag does not have open tag and it have only close tag.
Syntax:
<TagName/>
Example: <hr/>
<br/> etc.
• <font>: This tag is used to define font format in web page like that font color, size and
family
Attribute of <font> Tag:
1. Size: To give size of font
2. Color : To give color of font
3. Face: To give family of font
Color format :
A color gives two type name wise and hexadecimal wise
Name wise: red , green , blue etc.
Hexadecimal wise :
Blue
Red
#00 00 00
Example: Green
#000000 Black #ff0000 Red #00ff00 Green #0000ff Blue #ffffff White
<!--Font Attribute-->
<!DOCTYPE HTML>
<html> Output screen
<head>
<title>Font</title>
</head>
<body>
<h1><font color="#ff0000" size="14px" face="algerian">Font attributes</font></h1>
</body>
</html>
• <img>: This tag is used to insert a picture in web page and it is an empty tag does not
have open tag.
Attributes of <img> Tag:
1. Width &Height: To give width and height of <Img> tag
2. Border : To give border of picture
3. Src (Source) : To give source of picture
4. Align: To give alignment of the image like that lift , right, center.
5. Hspace: To give horizontal space of image Output screen
6. Vspace: To give vertical space of image
<!--Image tag Attribute-->
<!DOCTYPE HTML>
<html>
<head>
<title>Image</title>
</head>
<body>
<h1>Image attributes</h1> <img src="images/a.jpg" alt="sea" width="150px"
height="100px" hspace="20px" vspace="20px" />
</body>
</html>
List in html: List is a collection of data When do you want to display data in list format we can
use it. There are three type list as following.
1. Order list
2. Unorder list
3. Definition list
1).Order List: To display data in order list in web browser like that numeric , alphabetically ,
roman number .etc.
There are some tag as following.
• <ol> : To define order list
• <li> : To define list item
Attributes of order list
Type: To give type of list like that numeric , alphabetically , roman number .etc.
• Start : Where do you want stat list
Example 1:
<!--Order List--> Output screen
<!DOCTYPE HTML>
<html>
<head>
<title>Order List</title>
</head>
<body>
<h1><font color="#ff0000">Color List</font></h1>
<ol>
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</ol>
2).Unorder List: To display data in unorder list in web browser like that bullets ,circle ,square
,rectangle etc.
There are some tag as following.
• <ul> : To define unorder list
• <li> : To define list item
Attributes of unorder list
• Type: To give type of list like that bullets ,circle ,square ,rectangle etc.
Example 1:
Output screen
<!DOCTYPE html>
<html>
<head>
<title>Unoder List</title>
</head>
<body>
<h1><font color="#ff7080">Friend List</font></h1>
<ul>
<li>Zoya</li>
<li>Ankit</li>
<li>Salman</li>
</ul>
<Marquee>:The HTML marquee tag is used to scroll text or images across a web page.
and direction up, down, left, or right and create news tickers, dynamic headers, or footers.
and draw attention to important information.
Attributes <marquee> Tags
• Direction: Specifies direction in which the marquee scrolls.
• Behavior: Defines behavior of marquee default value smooth , alternate
• Scrolldelay: Sets delay in milliseconds between each movement.
• Scrollamount: Sets amount or speed of scrolling at each interval in pixels.
• Loop: Provides how many times the marquee will loop.
• Width: Provides width of a marquee.
• Height: Provides height of a marquee.
• Bgcolor: Provides background color of a marquee.
• Vspave : To provides vertical space color of a marquee.
• Hspave : To provides horizontal space color of a marquee.
<!DOCTYPE html>
<html>
<head>
<title>Marquee</title>
</head>
<body>
<marquee behavior="alternate" direction="right" width="100%" height="30px" bgcolor="blue"
scrolldelay="200px">
<font color="white">JIIT is a best institute</font>
</marquee>
<marquee direction="up" width="200px" height="300px" scrollamount="10px">
<img src="Images/a.jpg" alt="">
</marquee>
</body>
</html>
Output screen
Table:Table is a collection of rows and columns. This tag is used to display data in
rows and columns. there are some tag of table as following
1. <table>: This tag to defines Table.
2. <tr>: This tag to creates a row, which is a horizontal line in the table.
3. <th>:This tag to creates a header cell, which labels columns or provides
additional information about the data in the column.
4. <td>:This tag to define data of cell in Table, which contains the actual data.
• A Table data may be lists, paragraphs, forms, figures, preformatted text, other
tables, text, images, and links.
• When you're building a project that needs to represent data visually, HTML
tables are a good way to display information so it's easy to read and understand.
• You can customize HTML tables by adding row and column headings, and by
grouping rows together.
Attributes of <Table> tag:
1. Width and height: To give width and height of Table.
Padding
2. Border : To set border of Table.
3. Cellpadding : To give cell padding of table. Spacing
4. Cellspacing : To give space between cell of table.
5. Bgcolor : To give background color of table.
6. Align : To give align of table.
Example:
<!DOCTYPE html>
<html>
<head> <title>Table</title>
</head>
<body>
<table border="5px" bgcolor="silver" width="200px" height="200px"
cellpadding="5px" cellspacing="3px"> <tr> <th>Rno</th>
<th>Name</th>
<th>Course</th>
</tr><tr>
<td>101</td>
<td>Sumit</td>
<td>BCA</td> </tr></table></body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Table</title>
</head>
<body>
<table border="5px" bgcolor="silver" width="200px" height="200px" cellpadding="5px"
cellspacing="3px">
<tr>
<th colspan="3">Welcome</th>
</tr>
<tr>
<td>1</td>
<td rowspan="3"><img src="Images/a.jpg" width="150px" height="100px" ></td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>5</td>
</tr>
<tr>
<td>3</td>
<td>6</td>
</tr>
<tr>
<th colspan="3">Thanks</th>
</tr>
</table>
</body>
</html>
Link in HTML: Links are Hyperlinks to click any text and image and transfer controller
particular page.
<a> Tag :It is an anchor tag and it used to define link in web page and default unvisited link of
color blue and visited link color purple.
Attributes of <a> tag:
1. Name: To give name of anchor tag
2. href: To give reference or source path of anchor tag
3. target : To set target of links document should be opened, such as in a new tab _blank
and default self.
4. title: To Provides text that appears when the user hovers over a link.
5. rel: It Specifies the relationship between the source and the target document.
Auto download links:
Example:
<a href=”notes.pdf”>Coaching notes</a>
<a href=”bca.txt”>About BCA</a>
<a href=”Img.jpg”>Photo</a>
<!DOCTYPE html>
<html>
<head>
<title>Links </title>
</head>
<body>
<h1>Links</h1>
<table width="100%" bgcolor="blue" border="5px">
<tr>
<th><a href="Home.html"><font color="white">Home</font></a></th>
<th><a href="Contact.html"><font color="white">Contact</font></a></th>
<th><a href="Gellary.html"><font color="white">Gellary</font></a></th>
<th><a href="About.html"><font color="white">About</font></a></th>
</tr>
</table>
</body>
</html>
Output screen
<form> tag: This tag to contain input elements like text fields, checkboxes, and
buttons. It used to transfer data on server from web page
Attributes <form> tag
action: It provides submission format where do you want controller of web page
method: It used to upload data on server with GET and POST methods GET is a
default method and Post provide security and hide resource data in URL Locator
Example:
<form action=”demo.php” method=”post”>
• <Input>: This tag is used to create textbox , radio button , checkbox , submit button ,reset
button etc.
Attributes of <input> Tag:
1. Value / Size / Type /name: These options are used to give value , size ,name and type of
input tag.
Example:
<form action="">
<input type="text" value="Enter Name:" size="30"/>
</form>
<form action="">
<input type="password" size="30"/>
</form>
<form action="">
<input type="checkbox" value="Music" name="hoby[]" />Music
<input type="checkbox" value="Sport" name="hoby[]"/>Sport
</form>
<form action="">
<input type="text" value="About JIIT" size="30" readonly />
</form>
<form action="">
<input type="text" value="About JAVA" size="30" disabled />
</form>
Output screen for Disabled
4 Maxlength : To set length of text box
<form action="">
<input type="text" value="C is high level language" maxlength="20"/>
</form>
Output screen for maxlength
5 Required: It used to must be filled text box and empty text box not allowed
<form action="">
<input type="text" name="name" size="30" required />
<input type="submit" value="Search" name="submit">
</form>
<form action="">
<input type="text" name="name" size="30" placeholder="Enter your name:" />
</form>
11.file/multiple: file type of input to provide choose file with multiple file from storage
<form action="">
<input type="file" name="name" multiple/>
</form>
12.Email: It used to display error when give incomplete email in text box
<form action="">
<input type="email" name="Email" />
<input type="submit" name="submit" value="Login" />
</form>
13. Number: To provide number with start and end range with step
<form action="">
<input type="number" name="age" min="0" max="100" step="5" />
</form>
<form action="">
<input type="date" name="dob" min="2000-01-01" max="2050-01-01"/>
</form>
<form action="">
<input type="range" name="height" min="0" max="100"/>
</form>
• <Select>: This tag is used to create drop down or selection box in web page.
• <Option>: This tag to create option of select tag.
<form action="">
<label>City:</label>
<select name="city">
<option value="Agra">Agra</option>
<option value="Lucknow">Lucknow</option>
<option value="Mumbai">Mumbai</option>
</select>
</form>
<form action="">
<label>Address:</label><br>
<textarea name="add" cols="5" rows="5" ></textarea>
</form>
Registration form:
<!DOCTYPE html>
<html>
<head>
<title>Registration</title>
</head>
<body>
<h2>Register</h2>
<form action="#" method="POST">
<table> <tr>
<th>User Name</th>
<td><input type="text" name="uname" size="30" placeholder="User Name" required></td>
</tr> <tr>
<th>Password</th>
<td><input type="password" name="PWD" size="30" placeholder="Enter Passwor" required></td>
</tr> <tr>
<th>Gender</th>
<td><input type="radio" name="Gender" value="Male" checked/>Male
<input type="radio" name="Gender" value="Female"/>Female</td>
</tr> </tr> <th>Hobbies</th><td>
<input type="checkbox" name="hob[]" value="Music">Music
<input type="checkbox" name="hob[]" value="Cricke"> Cricket
<input type="checkbox" name="hob[]" value="Gym" checked>Gym
</tr> <tr>
<th>City</th><td>
<select name="city">
<option value="Select">Select</option>
<option value="Mumbai">Mumbai</option>
<option value="Delhi">Delhi</option>
<option value="Lucknow">Lucknow</option>
</select> </td> </tr> <tr>
<th>Address</th><td>
<textarea cols="30" rows="5"></textarea></td>
</tr> <tr>
<th colspan="2">
<input type="submit" name="submit" value="submit"/>
<input type="reset" name="reset" value="reset"/>
</th> </tr>
</table> </form> </body> </html>
MPEG .mpg MPEG. Developed by the Moving Pictures Expert Group. The first popular
.mpeg video format on the web. Not supported anymore in HTML.
AVI .avi AVI (Audio Video Interleave). Developed by Microsoft. Commonly used
in video cameras and TV hardware. Plays well on Windows computers,
but not in web browsers.
WMV .wmv WMV (Windows Media Video). Developed by Microsoft. Commonly used
in video cameras and TV hardware. Plays well on Windows computers,
but not in web browsers.
QuickTime .mov QuickTime. Developed by Apple. Commonly used in video cameras and
TV hardware. Plays well on Apple computers, but not in web browsers.
RealVideo .rm RealVideo. Developed by Real Media to allow video streaming with low
.ram bandwidths. Does not play in web browsers.
WebM .webm WebM. Developed by Mozilla, Opera, Adobe, and Google. Supported by
HTML.
MPEG-4 .mp4 MP4. Developed by the Moving Pictures Expert Group. Commonly used
or MP4 in video cameras and TV hardware. Supported by all browsers
and recommended by YouTube.
Video Tag: This tag is used to display video on web browser with different extension
Attribute Description
src It specifies to give URL of video
controls To displays controls button of video like that play, pause,volume.
autoplay It provides Start playing video automatically when the page loads.
loop To repeats video with the certain condition is true .
muted It provides mutes the video by default.
poster Specifies an image to be displayed before the video starts.
preload Specifies how the browser should load the video (auto, metadata, or none).
width & height Defines width and height of video.
Attribute Description
src It give source of video
type To define type of media
Output screen
<!DOCTYPE html>
<html>
<head>
<title>Video</title>
</head>
<body>
<video width="250px" height="250px" autoplay controls>
<source src="videos/a.mp4" type="video/mp4">
</video>
</body>
</html>
Audio Tag: This tag is used to display audio on web browser with different extension
Attribute Description
src It specifies to give URL of audio
controls To displays controls button of audio like that play, pause,volume.
autoplay It provides Start playing audio automatically when the page loads.
loop To repeats audio with the certain condition is true .
muted It provides mutes the audio by default.
poster Specifies an image to be displayed before the audio starts.
preload Specifies how the browser should load the audio (auto, metadata, or none).
Attribute Description
src It give source of audio
type To define type of media
<!DOCTYPE html>
<html>
<head>
<title>Audio</title>
</head>
<body>
<audio autoplay controls>
<source src="audios/a.mp3" type="audio/mpeg">
</audio>
</body>
</html>
Output screen
<object> Tag
It is used to embed images, videos, Audios , other extension files PDFs, Java applets, or other
multimedia content in a webpage.
Attributes of <object> Tag:
Attribute Description
data To give URL of object (file path).
type To give type of object (e.g., application/pdf, image/png).
Width To give width of object.
height To give height of object.
name To give name of object.
<!DOCTYPE html>
<html>
<head>
<title>Object Tag</title>
</head><body>
<object data="Data.pdf" type="application/pdf" width="800" height="600">
Your browser does not support PDF viewing. <a href="Date.pdf">Download PDF</a>
</object><br/> <object data="https://www.w3schools.com/html" width="100" height="100">
Your browser does not support the object element. <a href="https://www.w3schools.com/html">Visit
Website</a>
</object> <br/> <object data="Images/a.jpg" type="image/png" width="150" height="150">
Your browser does not support displaying this image.
</object> <object data="Marquee_P7.html" width="200" height="150">
Your browser does not support the object element. <a href="Marquee_P7.html">HTML file</a>
</object><br> <object data="videos/a.mp4" width="200" height="200">
Your browser does not support the object element.
</object> <object data="audios/b.mp3" width="200" height="100">
Your browser does not support the object element.
</object>
</body>
</html>
Output screen
Embed Tag: This tag is used to embed or display images, audios, videos, and file with different
extension on web page.
Attribute Description
src To give URL of embedded tag
type To give type file like .wav, .mp3, .mp4, .mpg, .wmv, and .avi.
width To give width of embedded tag.
height To give height of embedded.
autoplay Automatically starts playing the media (for audio/video).
loop Repeats the media audio and video.
<!DOCTYPE html>
<html>
<head>
<title>Object Tag</title>
</head><body>
<embed src="Images/b.jpg" type="image/png" width="150" height="150"/>
<embed src="Marquee_P7.html" width="200" height="150"/><br/>
<embed src="videos/b.mp4" width="200" height="200"/>
<embed src="audios/a.mp3" width="200" height="100"/><br/>
</body></html>
Output screen
Attribute Description
src To give source or URL of iframe.
width Defines width of iframe (in pixels or percentage).
height Defines height of iframe.
title Set title in text description of iframe
name To give name of iframe
sandbox It provides security restrictions, such as preventing scripts from running.
allow It provides permissions like fullscreen, camera, microphone, etc.
allowfullscreen It provides full screen of iframe.
frameborder To set border of iframe (0 for no border, 1 for a border).
loading Controls how iframe is loaded (lazy for delayed loading).
Display Website
<!DOCTYPE html>
<html>
<head>
<title>iframe</title>
</head>
<body>
<iframe src="https://www.wikipedia.org" width="300" height="150"></iframe>
</body>
</html>
Output screen
Output screen
Output screen
Body Tag in HTML: This tag is used to define main content of a webpage and display all data in
web browser and contains text, images, links, videos, and other elements that make up the webpage's
structure and design.
<!DOCTYPE html>
<html>
<head>
<title>Body tag</title>
</head>
<body bgcolor="blue">
<h1><font color="white">JIIT Khandari Agra</font></h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Body tag</title>
</head>
<body background="Images/b.jpg">
<h1><font color="white">JIIT Khandari Agra</font></h1>
</body>
</html>
Output screen
<!DOCTYPE html>
<html>
<head>
<title>Body tag</title>
</head>
<body background="Images/b.jpg" text="red">
<h1>JIIT Khandari Agra</h1>
</body>
</html>
Links color of <body> tag
<!DOCTYPE html>
<html>
<head>
<title>Body tag</title>
</head>
<body link="red" alink="blue" vlink="Green">
<a href="#">Home</a><br/>
<a href="#">Contact</a><br/>
<a href="#">About</a><br/>
</body>
</html>
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Meta Tag Example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A beginner-friendly HTML tutorial.">
<meta name="keywords" content="HTML, Web Development, Coding">
<meta name="author" content="By JIIT">
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This page demonstrates the use of meta tags.</p>
</body>
</html>
Output screen
<div> (short for division) Tag:
This tag is a container element of html and reserved space in web page. Mostly use this tag for
design by CSS styling.
<button> Tag:
This tag is used to create a clickable button. It can be used to submit forms, trigger JavaScript
functions.
Example:
<button>Click Me</button>
Symbols in HTML
Symbol is a special character that displayed on web page using HTML entities.
symbols mathematical operators, currency symbols, arrows, Greek letters, and
special characters that are not available on a standard keyboard.
Example:
© → © (Copyright Symbol)
Special Characters:
Mathematical Symbols
+918630879950
md.jakirmadh@gmail.com
Index of CSS-Style
What is CSS3:
CSS is a Cascading style sheets. It used to design elements of HTML and CSS is a cornerstone
technology of the World Wide Web, alongside HTML and JavaScript. it was developed by Håkon
Wium Lie and Bert Bos in 10 october1994 at the European Organization for Nuclear Research
(CERN) there are option to design by css.
Syntax of CSS
selector {
property: value;
……………………
……………………
……………………
}
Declaration Block: To declare block with curly brackets {} and terminate each statement by
semicolon.
Example of CSS :
p{
color: blue;
}
Selector of CSS :
Selectors are used to select particular element of html and give css style
There are some selectors as following.
Type of selector
1. Element Selector
2. Id Selector
3. Class Selector
4. Universal Selector
5. Group Selector
1)Element Selector
This selector is used to select elements of HTML by name
Example:
h1{
color:red;
font-family: algerian;
}
</style>
</head>
<body>
<h1> Element Selector</h1>
</body>
</html>
2)Id Selector
Id selector is used to select elements of HTML. it must be unique and define
with # keyword
Syntax of id selector:
#id-name {
property: value;
}
.cls{
color:white;
font-variant:small-caps;
background-color: #0000ff;
}
</style>
</head>
<body>
<h1 class="cls">This is a class Selector</h1>
</body>
</html>
Output screen
4)Universal Selector:This selector to provide selection of all element on an html page and
represent asterisk (*) symbol mostly use this selector when do you want to give same style all elements of html.
Syntax of universal selector: *{
property: value;
}
Example of Universal selector:
Output screen
<!DOCTYPE html>
<html>
<head>
<title>Universal Selector</title>
<style>
*{
color:white;
font-variant:titling-caps;
background-color: #00ff00;
}
</style>
</head>
<body>
<h1 class="cls">This is an universal Selector</h1>
</body>
</html>
5)Group Selector: Group selector are used to select multi tag and give CSS style
Syntax of group selector: tag1,tag2,tag3 { property: value; }
Output screen
<!DOCTYPE html>
<html>
<head>
<title>Group Selector</title>
<style>
h1, #k1, .k2 {
color: blue;
font-family:algerian;
border:5px solid green;
} </style>
</head>
<body>
<h1>This is group Selector 1</h1>
<h3 id="k1">This is group Selector 2</h3>
<h4 class="k2">This is group Selector 2</h4>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Inline Style Example</title>
</head>
<body>
<h1 style="color: purple;">Welcome to My Page</h1>
<p style="font-size: 16px; color:#ffff;background-color: blue;">This paragraph has inline styles
applied directly.</p>
</body>
</html>
Output screen
Example:
<!DOCTYPE html>
<html>
<head>
<title>Internal CSS </title>
<style>
body {background-color: bisque; }
h1 {
color: blue;
text-align: left; }
p{
font-size: 18px;
color:#00ff00; }
.d1 {
color: red;
font-weight: bold; }
</style>
</head> Output screen
<body>
<h1>Welcome to My Website</h1>
<p>This is a paragraph styled using internal CSS.</p>
<p class="d1">This paragraph has a special class applied.</p>
</body>
</html>
External CSS Style:
This type style is used to give single css style page add to multiple page and you want to make
changes on multiple pages.
It uses the <link> tag on every pages and the <link> tag should be put inside the head section.
Syntax of external Style:
Linking the External CSS File
<html><head>
<link rel="stylesheet" href="filename.css">
</head><body>
<!-- HTML content -->
</body></html>
<!DOCTYPE html>
<html>
<head>
<title>External CSS Demo</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Site Header</h1>
</header>
<p class="content">This is the main content of the page.</p>
<button>Click Me</button>
</body>
</html>
h1 {
color: darkred;
font-size: 28px;
text-transform: uppercase;
}
.content {
font-size: 18px;
color: #555;
margin: 20px;
}
button {
background-color: blue;
color: white;
padding: 10px 20px;
Output screen
<!DOCTYPE html>
<html>
<head>
<title>Color</title>
<style>
h1 {
color: blue;}
p{
color: #ff5733;}
span {
color: rgb(34, 139, 34);}
button {
color: rgba(255, 0, 0, 0.7); }
h2 {
color: hsl(240, 100%, 50%); opacity: 0.5;}
</style>
</head>
<body>
<h1>Heading 1st blue color</h1>
<p>Paragraph color </p>
<span>Span tag color</span>
<button>Button Color</button>
<h2>Heading 2nd Color</h2>
</body>
</html>
Output screen
2) Text Alignment & Direction: When do you want to give alignment of text then use it like that
Left , Right , Center, justify
<!DOCTYPE html>
<html lang="en">
<head>
<title>Text-Align</title>
<style>
h1 { text-align: left; }
h2 { text-align: center; }
h3 { text-align: right; }
p { text-align: justify; }
</style>
</head>
<body>
<h1>Text-Align left</h1>
<h2>Text-Align center</h2>
<h3>Text-Align right</h3>
<p>Text-Align justify</p>
</body>
</html>
3)Text-Indent & Spacing : there are some text properties to control spacing between letters,
words, and indentation.
<!DOCTYPE html>
<html>
<head>
<title>Text Spacing Example</title>
<style>
body {
font-family: 'Times New Roman', Times, serif;
background-color: #f4f4f4; }
p{
letter-spacing: 2px;
word-spacing: 5px;
line-height: 1.5;
text-indent: 50px;
font-size: 18px;
color: #333; }
</style>
</head>
<body>
<h2>CSS Text Spacing Example</h2>
<p> Agra is a smart city for visitors.
Agra is a smart city for visitors.
Agra is a smart city for visitors.
Agra is a smart city for visitors.
Agra is a smart city for visitors.
Agra is a smart city for visitors.
</p>
</body>
</html>
4)Text -Decoration:
This property is used to give text style like that underline, overline, strike through.
text-decoration-style Specifies the style (solid, dotted, dashed, etc.). text-decoration-style: dashed;
<!DOCTYPE html>
<html lang="en">
<head>
<title>Text Decoration Example</title>
<style>
body {
font-family: 'Times New Roman';
background-color: #f9f9f9;
}
p{
text-decoration: underline;
text-decoration-color: red;
text-decoration-style: dashed;
text-decoration-thickness: 3px;
text-underline-offset: 2px;
font-size: 20px;
color: #333; }
</style>
</head>
<body>
<h2>CSS Text Decoration Example</h2>
<p>
To give all text properties in this paragrabh,
To give all text properties in this paragrabh
</p>
</body>
</html>
5)Text -Transform: This property is used to change case upper , lower, capitalize.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Text Transform Example</title>
<style>
body {
font-family:'Times New Roman';
background-color: #f4f4f4; color:red;}
.uppercase {
text-transform: uppercase;}
.lowercase {
text-transform: lowercase;}
.capitalize {
text-transform: capitalize;}
</style>
</head>
<body>
<h2>CSS Text Transform Example</h2>
<p class="uppercase">this text will be converted to uppercase.</p>
<p class="lowercase">THIS TEXT WILL BE CONVERTED TO LOWERCASE.</p>
<p class="capitalize">this text will be capitalized correctly.</p>
</body>
</html>
white-space Controls how text wraps (normal, nowrap, pre, etc.). white-space: nowrap;
word-break Specifies how words should break at the end of a line. word-break: break-all;
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Text Overflow Example</title>
<style>
body {
font-family: 'Times New Roman';
background-color: #f4f4f4; color:blue; }
.nowrap {
white-space: nowrap;
width: 200px;
border: 1px solid black;
overflow: hidden; }
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 200px;
border: 1px solid black; }
.break-word {
overflow-wrap: break-word;
width: 200px;
border: 1px solid black;}
.break-all {
word-break: break-all;
width: 200px;
border: 1px solid black; }
</style>
</head>
<body>
<h2>CSS Text Overflow Example</h2>
<p class="nowrap">
This text will not wrap even if it exceeds the container width.
</p>
<p class="ellipsis">
This is a long text that will be truncated with an ellipsis if it overflows.
</p>
<p class="break-word">
ThisIsAReallyLongWordThatWillBreakAtTheRightPlaceToFitTheContainer.
</p>
<p class="break-all">
SupercalifragilisticexpialidociousWillBreakAnywhere.
</p>
</body>
</html>
7) Text Shadow:
This properties is used to give shadow of text.
Syntax:
text-shadow: horizontal-offset vertical-offset blur-radius color;
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Text Shadow Example</title>
<style>
body {
font-family: 'Times New Roman';
background-color: #f4f4f4;
text-align: center; }
.shadow1 {
text-shadow: 2px 2px 5px gray;
font-size: 30px;
color: black; }
.shadow2 {
text-shadow: -3px -3px 3px red;
font-size: 30px;
color: black; }
.shadow3 {
text-shadow: 4px 4px 0px blue, 6px 6px 0px red;
font-size: 30px;
color: black;}
</style>
</head>
<body>
<h2 class="shadow1">Soft Shadow Example</h2>
<h2 class="shadow2">Red Offset Shadow</h2>
<h2 class="shadow3">Multiple Shadows</h2>
</body>
</html>
Background in CSS-3:
1)background-color
2)background-image
3)background-repeat
4)background-attachment
5)background-position
6)background (shorthand property)
1)Background-Color: To give color of selected element.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
Value Description
repeat Default, repeats both horizontally and vertically.
no-repeat Prevents image repetition.
repeat-x Repeats horizontally only.
repeat-y Repeats vertically only.
<!DOCTYPE html>
<html>
<head>
<title>CSS Background Repeat Example</title>
<style>
body {
background-image: url('images/a.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
font-family:'Times New Roman';
text-align: center;
color: white;
padding: 20px;
}
.repeat-x {
background-image: url('images/b.jpg');
background-repeat: repeat-x;
background-color: lightgray;
padding: 20px;
margin: 20px auto;
width: 80%;
border-radius: 10px;
}
.repeat-y {
background-image: url('images/d.jpg');
background-repeat: repeat-y;
padding: 20px;
margin: 20px auto;
width: 80%;
border-radius: 10px;
color: red;
}
.repeat-both {
background-image: url('images/e.jpg');
background-repeat: repeat;
background-color: white;
padding: 20px;
margin: 20px auto;
width: 80%;
border-radius: 10px;
border: 1px solid #ccc; }
.no-repeat {
background-image: url('images/c.jpg');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
padding: 50px;
margin: 20px auto;
width: 80%;
border-radius: 10px;
border: 1px solid #ccc;
background-color: #f8f8f8; }
</style></head><body>
<h1>CSS Background Repeat Example</h1>
<div class="repeat-x">
This div has a background image that repeats **horizontally**.</div>
<div class="repeat-y">
This div has a background image that repeats **vertically**.</div>
<div class="repeat-both">
This div has a background image that repeats **both horizontally and vertically**. </div>
<div class="no-repeat">
This div has a background image that **does not repeat**. </div>
</body>
</html>
Output screen
Value Description
scroll Background scrolls with content (default).
fixed Background stays fixed while content scrolls.
local Background scrolls with element's content.
Syntax
element{ background-image: url("image");
background-attachment: fixed or scroll; }
<!DOCTYPE html>
<html>
<head>
<title>CSS Background Attachment Example</title>
<style>
body { font-family:'Times New Roman'; }
.fixed-bg {
background-image: url('images/a.jpg');
background-attachment: fixed;
background-size: cover;
background-repeat: no-repeat;
height: 100px;
width:600px ;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 2em; }
.scroll-bg {
background-image: url('images/b.jpg');
background-attachment: scroll;
background-size: cover;
background-repeat: no-repeat;
height: 100px;
width:600px ;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 2em; }
.local-bg-container {
width: 41%;
height: 100px;
overflow: auto;
border: 2px solid #ccc;}
.local-bg {
background-image: url('images/c.jpg');
background-attachment: local;
background-repeat: repeat;
background-size: contain;
padding: 20px;
height: 600px;
color: white;
font-weight: bold;}
</style>
</head>
<body>
<h1>CSS Background-Attachment Example</h1>
<div class="fixed-bg">
background-attachment: fixed</div>
<div class="scroll-bg">
background-attachment: scroll </div>
<div class="local-bg-container">
<div class="local-bg">
background-attachment: local<br/><br/>
Scroll inside this box to see how the background moves with the content.
</div></div></body></html>
background-color: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold; }
.center {
background-position: center; }
.top-left {
background-position: top left; }
.bottom-right {
background-position: bottom right; }
.custom-px {
background-position: 50px 30px; }
.custom-percent {
background-position: 75% 25%; }
</style>
</head>
<body>
<h3>CSS background-position Examples</h3>
<div class="box center">center</div>
<div class="box top-left">top left</div>
<div class="box bottom-right">bottom right</div>
<div class="box custom-px">50px 30px</div>
<div class="box custom-percent">75% 25%</div>
</body>
</html>
Box model: It provide margin , padding ,border style selected elements of html.
1)Margin
2)Padding
3)Border
4)Border-radius
5)Float (Position)
1) Margin : This property is used to define margin around elements like that left right top
bottom and provide out side space.
.box2 {
background-color: #3498db;
color: white;
padding: 20px;
margin: 5px 30px 5px 20px; }
.box3 {
background-color: #2ecc71;
color: white;
padding: 20px;
margin: 10px auto 10px; }
.box4 {
background-color: #9b59b6;
color: white;
padding: 20px;
margin: 5px 60px; }
.box5 {
background-color: #f39c12;
color: white;
padding: 20px;
margin: 5px; }
</style>
</head>
<body>
<h1>CSS Margin Properties Example</h1>
<div class="container">
<div class="box1">Individual Margin Properties</div>
<div class="box2">Shorthand: 4 Values (top, right, bottom, left)</div>
<div class="box3">Shorthand: 3 Values (top, sides, bottom)</div>
<div class="box4">Shorthand: 2 Values (vertical, horizontal)</div>
<div class="box5">Shorthand: 1 Value (all sides)</div>
</div> </body> </html>
Output screen
2) Padding : This property is used to give padding of sleeted elements and provide inside space.
.box4 {
background-color: #9b59b6;
padding: 15px 40px;
}
.box5 {
background-color: #f39c12;
padding: 25px;
}
</style></head><body>
<h3>CSS Padding Properties Example</h3>
<div class="container">
<div class="box box1">Individual Padding Properties</div>
<div class="box box2">Shorthand: 4 Values (top, right, bottom, left)</div>
<div class="box box3">Shorthand: 3 Values (top, sides, bottom)</div>
<div class="box box4">Shorthand: 2 Values (vertical, horizontal)</div>
<div class="box box5">Shorthand: 1 Value (all sides)</div>
</div>
</body>
</html>
Output screen
3)Border in CSS: This property is used to give outline or border selected element of HTML
And provide border color , size , style etc.
Border properties:
1.Border-color
2.Border-style 3.Border-width
4.Border Shorhand Properties
<!DOCTYPE html>
<html>
<head>
<title>CSS Border Properties Example</title>
<style>
body { text-align: center;}
.container {
width: 90%;
max-width: 800px; }
.box {
width: 80%;
margin: 20px;
padding: 20px;
background-color: white;
font-weight: bold; }
.box1 {
border: 3px solid #3498db; }
.box2 {
border-width: 4px;
border-style: dashed;
border-color: #e74c3c; }
.box3 {
border-top: 5px solid green;
border-right: 5px dashed blue;
border-bottom: 5px dotted purple;
border-left: 5px double orange; }
</style>
</head>
<body>
<h3>CSS Border Properties Example</h3>
<div class="container">
<div class="box box1">Shorthand: border</div>
<div class="box box2">Individual: width, style, color</div>
<div class="box box3">Different borders on each side</div> </div>
</body>
</html>
1. border-top-left-radius
2. border-top-right-radius
3. border-bottom-right-radius
4. border-bottom-left-radius
5. border-radius (shorthand)
Example:
<!DOCTYPE html>
<html>
<head>
<title>CSS Border-Radius Example</title>
<style>
body {
padding: 30px;
text-align: center; }
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px; }
.box {
width: 150px;
height: 100px;
background-color: #3498db;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;}
.box1 { border-radius: 0;}
.box2 { border-radius: 15px;}
.circle {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #2ecc71;}
.pill {
width: 150px;
height: 50px;
border-radius: 25px;
background-color: #f39c12; }
.box3 {border-radius: 10px 20px 30px 40px;}
.box4 { border-radius: 50px / 25px;}
.box5 {
border-top-left-radius: 20px;
border-top-right-radius: 20px; }
.box6 {
border-bottom-left-radius: 30px;
border-bottom-right-radius: 10px; }
</style>
</head>
<body>
<h3>CSS Border-Radius Properties</h3>
<div class="container">
<div class="box box1">No Radius</div>
<div class="box box2">All Corners</div>
<div class="circle">Circle</div>
<div class="pill">Pill</div>
<div class="box box3">Custom Corners</div>
<div class="box box4">Elliptical</div>
<div class="box box5">Top Corners</div>
<div class="box box6">Bottom Corners</div>
</div></body></html>
5)Float: this property is used to give position of element left , right and none
<!DOCTYPE html>
<html lang="en">
<head> <title>Float</title> <style>
.d1{ border: 2px solid red;
width: 500px;
height: 200px;
padding: 15px; } #im1 {
width: 150px;
height: 100px;
float: right; }
#im2{
width: 150px;
height: 100px;
float: left;
padding: 0px 10px 10px 0px; }
</style></head><body>
<div class="d1">
<img src="Images/a.jpg" id="im1" alt="">
CSS Tutorial
CSS tutorial
CSS tutorial or CSS 3 tutorial provides basic and advanced concepts of CSS technology. Our CSS tutorial is
developed for beginners and professionals. The major points of CSS are given below:
<br><br>
<img src="Images/b.jpg" id="im2" alt="">
CSS Tutorial
CSS tutorial
CSS tutorial or CSS 3 tutorial provides basic and advanced concepts of CSS technology. Our CSS tutorial is
developed for beginners and professionals. The major points of CSS are given below:
</div>
</body>
</html>
List style in CSS: This style is used to define list style of elements there are some list properties as
following
List properties in CSS
1)list-style-type
2)list-style-position
3)list-style-image
4)list-style (Shorthand)
Example:
1)list-style-type: This properties is used to give type of list like that bullets Unordered List (square
,circle rectangle ,desc , none etc.) Ordered List (decimal, lower-alpha, upper-alpha, lower-roman,
upper-roman, decimal-leading-zero etc.)
Example: ul { list-style-type: square; } ol { list-style-type: upper-roman; }
2)list-style-position: This property is used to define position of list inside and outside
Example: ul { list-style-position: outside;} ul { list-style-position: inside;}
4)list-style (Shorthand): This property is used to give type ,position and image of list.
Syntax:
list-style: [list-style-type] [list-style-position] [list-style-image];
Example:
ul { list-style: square;}
ul { list-style: url('path/a.png');}
ul { list-style: none;}
<!DOCTYPE html>
<html><head><style>
.list-default {
list-style-type: disc; }
.list-none {
list-style: none;}
.list-square {
list-style-type: square;}
.list-roman {
list-style-type: upper-roman; }
.list-image {
list-style-image: url('Images/whatsapp.png'); }
.list-inside {
list-style-position: inside;
background-color: #f4f4f4;
padding: 10px;}
.list-outside {
list-style-position: outside;
background-color: #e0f7fa;
padding: 10px;}
</style></head><body>
<h3>Default Unordered List</h3>
<ul class="list-default">
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li></ul>
<h3>No Bullets</h3>
<ul class="list-none">
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li></ul>
<h3>Square Bullets</h3>
<ul class="list-square">
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li></ul>
<h3>Ordered List Roman No.</h3>
<ol class="list-roman"> <h3>Inside Position</h3>
<li>First</li> <ul class="list-inside">
<li>Second</li> <li>This bullet is inside the box</li>
<li>Third</li></ol> <li>Second item</li></ul>
<h3>Custom Bullet Image</h3> <h3>Outside Position</h3>
<ul class="list-image"> <ul class="list-outside">
<li>GitHub</li> <li>This bullet is outside the box</li>
<li>Twitter</li> <li>Second item</li></ul></body></html>
<li>LinkedIn</li></ul>
Links in CSS: Links properties are used to give visited color ,active color and hover of link.
Example:
a:link { color: blue;
text-decoration: none;}
a:visited {
color: purple;}
a:hover { color: orange;
text-decoration: underline;}
a:active { color: red;}
a:focus { outline: 2px solid #000;}
Pseudo-class Description
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Links Example</title>
<style>
a{ text-decoration: none;
color: #3498db;
font-weight: bold; }
a:visited {
color: #8e44ad; }
a:hover {
color: #e74c3c;
text-decoration: underline; }
a:active {
color: #2ecc71; }
a:focus {
outline: 2px dashed orange;}
.btn-link { display: inline-block;
background-color: #2980b9;
color: white;
padding: 10px 20px;
border-radius: 8px;
text-decoration: none;
transition: background-color 0.3s; }
.btn-link:hover {
background-color: #1abc9c; }
</style></head><body>
<h2>Normal Link Styling</h2>
<p><a href="https://www.w3schools.com/" target="_blank">Visit Example Website</a></p>
<h2>Button-style Link</h2>
<p><a href="https://chatgpt.com/" class="btn-link" target="_blank">Visit OpenAI</a></p>
</body></html>
Table: Table properties are used to give border , width , height and merge row and column ,
alignment , hover and create responsive table.
Properties of Table:
Property Description
border It used to give border of table, rows, or cells
border-collapse To merges adjacent cell borders (collapse) or separates
border-spacing To sets space between cells (used when border-collapse: separate)
width, height To give size of table or specific cells
table-layout To defines table layout algorithm (auto or fixed)
text-align It used to give aligns text horizontally in cells
vertical-align It used to give aligns text vertically in cells
padding Controls inner space inside <td> and <th>
background-color To sets background color of cells, rows, or header
caption-side Sets position of <caption> (top or bottom)
empty-cells Controls display of empty table cells (show or hide)
<!DOCTYPE html>
<html>
<head>
<title>CSS Table Properties</title>
<style>
table { width: 80%;
margin: 20px auto;
border-collapse: collapse;
table-layout: fixed; }
caption {
caption-side: top;
font-size: 1.5em;
margin-bottom: 10px; }
th, td {
border: 2px solid #333;
padding: 15px;
text-align: center;
vertical-align: middle;
background-color: #f9f9f9; }
th {
background-color: #0000ff;
color: white; }
tbody tr:nth-child(odd) {
background-color: #e0f7fa; }
tbody tr:hover {
background-color: #d1c4e9; }
.hide-empty {
empty-cells: hide; }
</style></head><body> <table>
<caption>Employee Table</caption>
<thead><tr>
<th>Name</th>
<th>Position</th>
<th>Location</th>
</tr></thead>
<tbody><tr>
<td>Ankit</td>
<td>Manager</td>
<td>Agra</td></tr><tr>
<td>Shivangi</td>
<td></td> <!-- Designer Empty cell -->
<td>Mathura</td></tr><tr>
<td>Salman</td>
<td>Developer</td>
<td>Lucknow</td></tr></tbody></table></body></html>
Overflow: This property is used to provide scrollbars and show and hide overflow in selected
elements
Value Description
hidden It does not visible outside content of box. No scrollbars, but content can be scrolled.
Syntax:
overflow: visible | hidden | clip | scroll | auto | [overflow-x] [overflow-y];
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Overflow Example</title>
<style>
.box {
width: 300px;
height: 100px;
padding: 10px;
border: 2px solid #333;
background-color: #fff; }
.visible {
overflow: visible;}
.hidden {
overflow: hidden; }
.scroll {
overflow: scroll; }
.auto {
overflow: auto; }
.overflow-x {
overflow-x: scroll;
white-space: nowrap;}
.content {
width: 433px;
height: 126px;
background-color: #ecf0f1; }
</style></head><body>
<h2>CSS Overflow Property Examples</h2>
<h3>overflow: visible</h3>
<div class="box visible">
<div class="content">visible is default and provide no scrollbars & display data outside.</div> </div>
<h3>overflow: hidden</h3>
<div class="box hidden">
<div class="content"> It does not visible outside content of box. No scrollbars, content can be scrolled and hide.
</div>
</div> <h3>overflow: scroll</h3>
<div class="box scroll">
<div class="content">Scrollbars always appear and content doesn't overflow.</div> </div>
<h3>overflow: auto</h3>
<div class="box auto">
<div class="content">Scrollbars only appear when needed.</div> </div>
<h3>overflow-x: scroll (horizontal scroll only)</h3>
<div class="box overflow-x">
<div class="content">This is a long line that scrolls horizontally only.</div>
</div>
</body></html>
Display property in CSS: Display property is used to display elements or block in webpage there
are some properties as following.
Value Description
block To give full width of element, starts on a new line (<div>)
inline It provide horizontal elements inline(<span>)
inline-block Display data with inline with width/height
none Hide elements
flex Turns container into a flexbox
grid Turns container into a CSS Grid
inline-flex Same as flex, but behaves like an inline element
inline-grid Same as grid, but inline
table Behaves like a <table>
list-item Behaves like a list item (<li>)
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Display Property</title>
<style>
.box {
background-color: #3498db;
color: white;
padding: 10px;
margin: 10px;
border-radius: 6px; }
.block {
display: block; }
.inline {
display: inline; }
.inline-block {
display: inline-block;
width: 120px; }
.none {
display: none; }
.flex-container {
display: flex;
gap: 10px; }
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px; }
</style></head><body>
<h2>display: block</h2>
<div class="box block">Block 1</div>
Position property in CSS: Position properties are used to give position selected elements , div ,
image , header ,footer etc. There are some properties as following.
Value Description
static It is a default property of position to provide flow top, left, etc and no effect.
relative This property to take position relative according to other element left , right ,top, bottom
absolute It used to give position and provide scrolling or moving . object according to relative element and
stop overflow
sticky It used to stick top , right ,bottom,left and not scroll element with the page
<!DOCTYPE html>
<html>
<head> <style>
.container {
position: relative;
height: 400px;
background: #f0f0f0;
border: 2px solid #ccc;
margin: 50px; }
.static-box {
position: static;
background: lightblue;
padding: 10px; }
.relative-box {
position: relative;
top: 20px;
left: 20px;
background: lightgreen;
padding: 10px; }
.absolute-box {
position: absolute;
top: 10px;
right: 10px;
background: salmon;
padding: 10px; }
.fixed-box {
position: fixed;
bottom: 1 0px;
right: 20px;
background: gold;
padding: 10px;
z-index: 10; }
.sticky-box {
position: sticky;
top: 0;
background: orchid;
padding: 10px;
z-index: 5; }
</style></head><body>
<div class="sticky-box">Sticky (sticks at top when scrolling)</div>
<div class="container">
<div class="static-box">Static (default)</div>
<div class="relative-box">Relative (20px down & right)</div>
<div class="absolute-box">Absolute (top-right corner of container)</div></div>
<div class="fixed-box">Fixed (bottom-right of viewport)</div></body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-size: 28px;}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: -webkit-sticky; /* Safari */
position: sticky;
top: 0;}
li {
float: left;}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;}
li a:hover {
background-color: #4CAF50;}
</style>
</head>
<body>
<ul>
<li><a href="#Home">Home</a></li>
<li><a href="#Gellary">Gellary</a></li>
<li><a href="#Contact">Contact</a></li>
<li><a href="#About">About</a></li>
</ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body { font-size: 28px;}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: blue;
position: -webkit-sticky; /* Safari */
position: sticky;
top: 0;
width:200px ;}
li a {
display: block;
color: white;
text-align: left;
padding: 14px 16px;
text-decoration: none;}
li a:hover {
background-color: red;}
</style></head><body>
<ul>
<li><a href="#Home">Home</a></li>
<li><a href="#Gellary">Gellary</a></li>
<li><a href="#Contact">Contact</a></li>
<li><a href="#About">About</a></li>
</ul></body></html>
<!DOCTYPE html>
<html><head><style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: blue;}
li { float: left;}
li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;}
li a:hover, .dropdown:hover .dropbtn {
background-color: red;}
li.dropdown { display: inline-block;}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;}
.dropdown-content a:hover {background-color: #d01111;
color:white;}
.dropdown:hover .dropdown-content { display: block;}
</style></head><body><ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">Dropdown</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div> </li> </ul> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head> <meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-
awesome.min.css">
<style> .nav-bar {
list-style: none;
padding: 0;
margin: 0;
display: flex;
background-color: rgb(28, 160, 28); }
.nav-bar li {
position: relative; }
.nav-bar a {
text-decoration: none;
padding: 10px;
display: block;
color: white;
font-size: larger; }
.dropdown-content {
display: none;
position: absolute;
top: 100%;
width: 175%;
left: 0;
list-style: none;
padding: 0;
margin: 0;
background-color: white;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown-content li a {
color: black;
padding: 10px;
display: block;
text-decoration: none;
}
.dropdown-content li a:hover {
background-color: rgb(202, 241, 202);
}
</style>
</head>
<body>
<nav> <ul class="nav-bar">
<li class="dropdown">
<a href="#"><i class="fa fa-bars"></i><i class="fa fa-bars"></i></a>
<ul class="dropdown-content">
<li><a href="#">Products</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Blog</a></li>
</ul> </li>
</ul> </nav>
</body>
</html>