🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Introduction
Button text can be made bold to enhance visibility and emphasize the button's action. CSS provides a simple way to achieve this using the font-weight property, which controls the thickness of the font.
In this tutorial, you’ll learn how to make button text bold using CSS.
Problem Statement
Create CSS code that:
- Displays a button with bold text.
- Adds a hover effect to further enhance the button's visibility.
Example:
- Input: A button element with the text "Submit".
- Output: A button with bold text that changes style on hover.
Solution Steps
- Use the
<button>Element: Create the button in HTML. - Make Text Bold Using CSS: Use the
font-weightproperty to style the button text. - Add Hover Effect (Optional): Further enhance the button on hover.
HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bold Button Text</title>
<style>
/* Step 1: Style the button and make the text bold */
.bold-button {
font-size: 1.2rem;
font-weight: bold; /* Makes the text bold */
color: white;
background-color: #3498db;
padding: 12px 30px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
/* Step 2: Add hover effect */
.bold-button:hover {
background-color: #2980b9; /* Darker blue on hover */
}
</style>
</head>
<body>
<div style="text-align: center; margin-top: 100px;">
<button class="bold-button">Submit</button>
</div>
</body>
</html>
Output
Explanation
Step 1: Make Button Text Bold
The .bold-button class is used to style the button and make the text bold.
.bold-button {
font-weight: bold; /* Makes the text bold */
}
font-weight: bold: This CSS property makes the button text bold.
Step 2: Add Hover Effect
A hover effect is added to change the button's background color when hovered.
.bold-button:hover {
background-color: #2980b9; /* Changes background color on hover */
}
Conclusion
You can make button text bold using the font-weight: bold property in CSS. This simple change improves readability and emphasis on the button's action.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment