🎓 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
Creating vertical text in CSS can be useful for specific design elements like sidebars, headers, or decorative text. CSS provides a way to display text vertically using the writing-mode property, which changes the text flow from horizontal to vertical.
In this tutorial, you'll learn how to create vertical text using the writing-mode property in CSS. This technique is helpful for creating unique layouts and designs.
Problem Statement
Create a CSS code that:
- Displays text vertically using the
writing-modeproperty. - Demonstrates how to control the flow of vertical text.
Example:
- Input: A div element with the text "Vertical Text Example".
- Output: The text is displayed vertically within its container.
Solution Steps
- Use
writing-modeProperty: Apply thewriting-modeproperty to change the text orientation from horizontal to vertical. - Control Text Flow: Use values like
vertical-rlorvertical-lrto control the direction of the vertical text.
HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vertical Text Example</title>
<style>
/* Step 1: Set text to flow vertically from right to left */
.vertical-text {
writing-mode: vertical-rl;
text-orientation: upright;
border: 1px solid #ccc;
padding: 10px;
width: 50px;
}
/* Step 2: Vertical text flowing from left to right */
.vertical-text-lr {
writing-mode: vertical-lr;
text-orientation: upright;
border: 1px solid #ccc;
padding: 10px;
width: 50px;
}
</style>
</head>
<body>
<div class="vertical-text">This text flows vertically (right to left).</div>
<br>
<div class="vertical-text-lr">This text flows vertically (left to right).</div>
</body>
</html>
Output
Explanation
Step 1: Use writing-mode: vertical-rl
- To display text vertically from right to left, use the following CSS:
.vertical-text { writing-mode: vertical-rl; text-orientation: upright; border: 1px solid #ccc; padding: 10px; width: 50px; }
Step 2: Use writing-mode: vertical-lr
- To display text vertically from left to right, use this CSS:
.vertical-text-lr { writing-mode: vertical-lr; text-orientation: upright; border: 1px solid #ccc; padding: 10px; width: 50px; }
Conclusion
Creating vertical text in CSS is simple using the writing-mode property. You can control the flow of the text using vertical-rl or vertical-lr to suit your design needs. This technique helps create visually appealing and unique layouts for web content.
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