Dividing text with CSS is easy! Our comprehensive guide for beginners will show you how to split text and create a visually appealing text layout.

Table of Contents
Splitting text is one of the most basic techniques for anyone who is trying to make their website more interesting or make content more readable. This can easily be accomplished using HTML and CSS, but it might seem daunting at first.
👏👏 I made it to 100k followers and it feels awesome! I’m so grateful to you all for always supporting me, sharing my content, and being a part of my journey.
Have you followed me on Instagram yet?💪
If you would like to get updates about my new projects and all other fun and exciting things, please follow me on Instagram.
Follow me here: @codewithfaraz
Let's start making an amazing splitting text using HTML and CSS step by step.
Prerequisites:
Before starting this tutorial, you should have a basic understanding of HTML and CSS. Additionally, you will need a code editor such as Visual Studio Code or Sublime Text to write and save your code.
Source Code
Step 1 (HTML Code):
First, we will start by creating a basic HTML document. We will need a container for the text as well as a header. We will also need a paragraph tag to hold the text together. Let's break down the HTML code step by step:
1. Head Section (<head>
)
<title>Split Text</title>
: Sets the title of the webpage.<meta charset="UTF-8">
: Defines the character encoding as UTF-8.<meta name="viewport" content="width=device-width">
: Makes the page responsive for different screen sizes.<link rel="stylesheet" href="styles.css">
: Links an external CSS file (styles.css
) for styling.
2.
Body Section (<body>
)
<div class="container">
: A wrapper that holds all content.<div class="text-box">
: A div containing two<h1>
elements with the text "100K FOLLOWERS".-
Why two
<h1>
elements?- This might be for a split text animation, where one text layer moves differently from the other.
-
Why two
-
<p>THANK<span> YOU 🙂</span></p>
:- Displays "THANK YOU 🙂" with "YOU
🙂" wrapped inside a
<span>
. - This could be used for styling effects (e.g., color change, animation, or font modifications).
- Displays "THANK YOU 🙂" with "YOU
🙂" wrapped inside a
After creating the files, just paste the following codes into your file. Remember that you must save a file with the .html extension.