🎓 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
Letter spacing in CSS allows you to control the space between characters in text. This can improve readability or create unique design effects for headers and body text.
In this tutorial, you'll learn how to apply letter spacing using the letter-spacing property in CSS. You can adjust the spacing between characters to enhance the visual appearance of your text.
Problem Statement
Create a CSS code that:
- Adjusts the space between characters using the
letter-spacingproperty. - Demonstrates different values for increasing or decreasing the spacing between letters.
Example:
- Input: A paragraph element with the text "Letter Spacing Example".
- Output: The text appears with increased or decreased spacing between characters.
Solution Steps
- Use
letter-spacingProperty: Apply theletter-spacingproperty to control the space between characters in the text. - Apply Positive and Negative Values: Use positive values to increase spacing and negative values to decrease spacing.
HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Letter Spacing Example</title>
<style>
/* Step 1: Set normal letter spacing */
.normal-spacing {
letter-spacing: normal;
}
/* Step 2: Increase letter spacing */
.increased-spacing {
letter-spacing: 2px;
}
/* Step 3: Decrease letter spacing */
.decreased-spacing {
letter-spacing: -1px;
}
</style>
</head>
<body>
<p class="normal-spacing">This text has normal letter spacing.</p>
<p class="increased-spacing">This text has increased letter spacing of 2px.</p>
<p class="decreased-spacing">This text has decreased letter spacing of -1px.</p>
</body>
</html>
Output
Explanation
Step 1: Use letter-spacing: normal
- To use default letter spacing, apply the following CSS:
.normal-spacing { letter-spacing: normal; }
Step 2: Increase Letter Spacing
- To increase the space between characters, use a positive value:
.increased-spacing { letter-spacing: 2px; }
Step 3: Decrease Letter Spacing
- To decrease the space between characters, use a negative value:
.decreased-spacing { letter-spacing: -1px; }
Conclusion
Applying letter spacing with CSS is simple using the letter-spacing property. You can adjust the spacing between characters using positive or negative values to enhance readability or create a unique visual style for your text.
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