MODULE 3 β CSS Fundamentals
π Lesson 3.8 β Styling Links & Buttons
π¨ Creating Attractive Hyperlinks, Buttons, and Hover Effects
π― Learning Objectives
After completing this lesson, students will be able to:
β Understand Hyperlinks and Buttons
β Style Links Using CSS
β Remove Underlines from Links
β Change Link Colors
β Use Hover Effects
β Create Professional Buttons
β Design Call-to-Action Buttons
β Build Modern Website Navigation
π Introduction
Imagine a website containing:
Home
About
Contact
Services
Simple text links look boring.
Now imagine:
[ Home ] [ About ] [ Services ] [ Contact ]
Beautiful colors.
Hover effects.
Professional design.
This is done using:
π Link Styling
and
π¨ Button Styling
π€ What are Links?
Links help users move from one page to another.
HTML uses:
<a>
tag for links.
Example
<a href="https://www.google.com">
Google
</a>
Default Link Appearance
Browser shows:
Blue Color
Underline
Example
<a href="#">
Home
</a>
Output
Blue underlined link.
π― Styling Links Using CSS
Example
a{
color:red;
}
Result
Link becomes red.
HTML
<a href="#">
Home
</a>
CSS
a{
color:blue;
}
Output
Blue link.
π Removing Underline
Professional websites usually remove underlines.
Syntax
text-decoration:none;
Example
a{
text-decoration:none;
}
Result
Link appears without underline.
Example
a{
color:blue;
text-decoration:none;
}
π¨ Changing Link Font
Example
a{
font-size:20px;
font-weight:bold;
}
Result
Large bold link.
π― Link States
CSS provides special states for links.
1οΈβ£ Normal Link
a:link{
color:blue;
}
2οΈβ£ Visited Link
a:visited{
color:purple;
}
Meaning
After clicking:
Link becomes purple.
3οΈβ£ Hover Link
Most important.
Syntax
a:hover{
color:red;
}
Meaning
When mouse moves over link:
Color changes.
Example
a:hover{
color:red;
}
Result
Blue β Red on hover.
4οΈβ£ Active Link
When user clicks.
a:active{
color:green;
}
Link State Order
Professional order:
a:link
a:visited
a:hover
a:active
π Complete Link Example
HTML
<a href="#">
Home
</a>
CSS
a{
text-decoration:none;
font-size:20px;
font-weight:bold;
}
a:link{
color:blue;
}
a:hover{
color:red;
}
Output
Blue Link
Hover β Red
No Underline
π― What is a Button?
Buttons allow users to:
β Submit Forms
β Navigate Pages
β Perform Actions
HTML Button
<button>
Click Me
</button>
Default Button
Simple gray button.
π Styling Buttons
Example
button{
background-color:blue;
color:white;
}
Result
Blue button with white text.
π¨ Button Background Color
Example
button{
background-color:green;
}
Button Text Color
Example
button{
color:white;
}
π Button Font Size
Example
button{
font-size:18px;
}
π Button Padding
Makes button bigger.
Example
button{
padding:10px;
}
Result
Larger button.
π Rounded Buttons
Example
button{
border-radius:10px;
}
Result
Rounded corners.
Example
button{
border-radius:25px;
}
Result
Pill-shaped button.
π― Button Border
Example
button{
border:2px solid blue;
}
Result
Blue border around button.
π― Button Hover Effect
Most important effect.
Example
button:hover{
background-color:red;
}
Result
Mouse Hover:
Blue β Red
Example
button:hover{
cursor:pointer;
}
Result
Hand cursor appears.
π Professional Button Example
HTML
<button>
Register Now
</button>
CSS
button{
background-color:blue;
color:white;
font-size:18px;
padding:12px 25px;
border:none;
border-radius:10px;
}
button:hover{
background-color:darkblue;
cursor:pointer;
}
Output
Modern Professional Button
π― Call-to-Action Button
CTA means:
Call To Action
Examples:
Register Now
Join Course
Learn More
Contact Us
Buy Now
Example
button{
background-color:orange;
color:white;
font-size:20px;
padding:15px 30px;
border-radius:30px;
}
Result
Eye-catching button.
π» Complete Example Program
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>NextGen Dev Hub</h1>
<a href="#">Home</a>
<a href="#">Courses</a>
<a href="#">Contact</a>
<br><br>
<button>
Register Now
</button>
</body>
</html>
CSS
body{
font-family:Arial;
}
a{
text-decoration:none;
color:blue;
font-size:20px;
margin:15px;
}
a:hover{
color:red;
}
button{
background-color:green;
color:white;
font-size:18px;
padding:10px 20px;
border:none;
border-radius:10px;
}
button:hover{
background-color:darkgreen;
cursor:pointer;
}
π― Expected Output
β Styled Navigation Links
β Hover Effects
β Professional Button
β Modern Appearance
π« Real World Example
College Website
Home
About
Courses
Contact
Styled navigation links.
Online Course Website
Enroll Now
Professional CTA button.
E-Commerce Website
Buy Now
Add to Cart
Styled buttons.
β οΈ Common Beginner Mistakes
Mistake 1
Not Removing Underlines
Default links look outdated.
Use:
text-decoration:none;
Mistake 2
Using Very Bright Colors
Wrong:
background-color:yellow;
color:white;
Hard to read.
Use good contrast.
Mistake 3
No Hover Effect
Buttons look inactive.
Always add:
:hover
π Best Practices
β Remove unnecessary underlines.
β Use hover effects.
β Use rounded buttons.
β Maintain consistent colors.
β Use CTA buttons for important actions.
π Mini Project β Navigation Menu
Create:
Home
About
Services
Contact
Apply:
β Blue Links
β No Underlines
β Hover Red
Create:
Register Now
Button with:
β Green Background
β White Text
β Rounded Corners
π Practical Activity
Create a webpage containing:
Navigation Menu
Home
About
Courses
Contact
Button
Enroll Now
Apply:
β Hover Effects
β Rounded Corners
β Professional Colors
Run it in Chrome Browser.
π Assignment
Assignment 3.8
- What is a hyperlink?
- Which HTML tag creates links?
- How do you remove underlines from links?
- What does
:hoverdo? - What is a CTA button?
- Create a navigation menu using styled links.
- Create a professional button with hover effects.
π§ Quiz
Q1. Which tag creates hyperlinks?
A. <link>
B. <a>
C. <href>
D. <url>
β Answer: B
Q2. Which property removes underlines?
A. remove-line
B. underline:none
C. text-decoration:none
D. text:none
β Answer: C
Q3. Which pseudo-class applies styles when the mouse moves over an element?
A. active
B. hover
C. click
D. focus
β Answer: B
Q4. Which property changes button background color?
A. color
B. button-color
C. background-color
D. fill
β Answer: C
Q5. Which property creates rounded corners?
A. corner
B. radius
C. border-radius
D. round
β Answer: C
π Lesson Summary
β
Links are created using the <a> tag.
β CSS can change link colors and remove underlines.
β
:hover creates interactive effects.
β Buttons can be customized using colors, borders, padding, and border-radius.
β Professional websites use hover effects and CTA buttons.
β Styled links and buttons improve user experience.