CSS Text Outline: How To Make Amazing Outlined Texts

Marilena

By Marilena

3 min read
Bookmark this post

Hello, there 😃 Let’s step into a digital world where CSS brings forth the captivating CSS text outline effect. It’s a simple yet powerful technique that adds structure and clarity to texts and elements.

Let’s dive into how CSS outlines 🖋 can make a significant difference in the visual appeal of your website. 💻 🫧

Create basic HTML and CSS structure

As a first step, we need some basic HTML structure to apply our CSS stylings.

<body>
  <div class="outline-effect">outline effect</div>
</body>
HTML
/* insert google fonts */
@import url(
  'https://fonts.googleapis.com/css2?family=Emilys+Candy&display=swap'
);

body {
  background-color: purple;
}

.outline-effect {
  width: 650px;
  font-size: 180px;
  text-align: center;
  font-family: 'Emilys Candy', cursive;
}
CSS

Let’s see what we have done so far. I have chosen a vibrant purple color for our background while keeping the text in the default black color. Our text is set to 180px, perfectly aligned to the center.

To give a playful and lively vibe to our design, I’ve chosen the “Emily Candy” font-family which adds a delightful touch. If you also intend to use this font family, importing it into your CSS file is essential. Ensure the @import statement is placed at the beginning of your CSS code snippet, just like I did (check above lines 2-4).

In the image below, you can see the current rendering on the screen up to this point.

Apply the CSS text outline effect

.outline-effect {
  ...
  text-stroke: 2px #8695e9; // medium blue shade
  color: transparent;
}
CSS

The first thing we have to do is set the text-stoke property which represents a specific style line. Here, in our example, the text should have a light to medium blue color (#8695e9) outline with 2 pixels wide. Remember that as we increase the pixels, the outline becomes wider.

🔖 It’s useful to know that we can split the text-stroke property in two: text-stroke-width and text-stroke-color.

/* 1st choice */
  text-stroke: 2px #8695e9;

/* 2nd choice */
  text-stroke-width: 2px;
  text-stroke-color:  #8695e9;
CSS

(Personally, I opt for the shortened form, saving time and extra lines of code, but the choice is yours. 🙂)

Finally, by adding color: transparent we complete our effect by allowing the background to show through.

So, to sum up, this code styles a piece of text with a see-through center and a visible shade of blue 2px outline. It’s simple yet impressive 🎈 ✨

🌼 Hope you found my post interesting and helpful. Thanks for being here! 🌼

DigitalOcean Referral Badge
guest
0 Comments
Inline Feedbacks
View all comments

Continue reading

Front, Programming

Grayscale Backdrop Filter: A Useful Tool To Make Grayish Backgrounds

Front, Programming

Awesome CSS Grayscale Filter – How to Upgrade Images

Front, Programming

Learn CSS Grayscale Filter the Easy Way: A Complete Guide

Front, Programming

Make a Unique Folded Corner Effect – Step By Step Guide

Front, Programming

How To Create Stunning Vibrant Neon Effect – CSS Only

Front, Programming

CSS Radial Gradient Techniques: How To Make Colorful Infinite Loops

Front, Programming

CSS Linear Gradient Techniques: How To Make Colorful Line Drawings

Front, Programming

CSS Conic Gradient Technique: How To Make Stunning Visual Effects

Front, Programming

How to Make A Blinking Animation Using CSS

Front, Programming

How To Make CSS Reflection – The Easy Way

Front, Programming

How To Create A Stunning Gray CSS Water Drop

Front, Programming

What Does span Do in HTML? Unlocking Its Full Potential

Subscribe to our newsletter

Dive into the Fun Side of Tech! Posts, News, and More Delivered to Your Inbox!

Intuit Mailchimp