CSS Code For Text Decoration

CSS Code For Text Decoration
Code Snippet:Fun with text-decoration
Author: Matt Smith
Published: January 19, 2024
Last Updated: January 22, 2024
Downloads: 1,312
License: MIT
Edit Code online: View on CodePen
Read More

This CSS code snippet demonstrate five different styles of text decoration property. It is helpful to make decorative text with wavy, dashed, double, dotted, and overline border style. After including this tiny CSS library, you can apply any decorations for your text by just using the class name.

How to Use CSS Code For Text Decoration

1. In order to apply text decoration to your text, wrap your text into a span element and define a class name for text decoration. The following are available classes to make different styles of text decorations.

  1. wavy
  2. dashed
  3. double
  4. dotted
  5. over
<h1>Fun with <code>text-decoration</code>!</h1>

<p><span class="wavy">The wavy underline is created with</span> <code>text-decoration: wavy underline</code>.</p>

<p><span class="dashed">A dashed underline uses</span> <code>text-decoration: dashed underline</code>.</p>

<p><span class="double">Add a splash of color...</span></p>

<p><span class="dotted">Like this:</span> <code>text-decoration: #f44336 dotted underline</code>.</p>

<p><span class="over">Even put a line <em>above</em> the text with</span> <code>text-decoration: underline overline</code>.</p>

<p>And for letters that drop below the underline (<span class="skip">the quick brown fox jumps over the lazy dog</span>): <code>text-decoration-skip: ink</code>.</p>

2. Add the following CSS styles into your project for all text decorations.

*:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;

body {
  font: 1.4em/1.75 sans-serif;
  margin: 1em;
   display: block !important;
h1 {
  font-size: 1.5em;
  margin-bottom: .5em;

p {
  margin-bottom: 1.5em; 
  display: block;

li {
  list-style: none;
  padding-bottom: .75em;

.wavy {
  text-decoration: #ec407a wavy underline;

.double {
  text-decoration: #a0f double underline;

.dashed {
  text-decoration: #26a69a dashed underline;

.dotted {
  text-decoration: #d50000 dotted underline;

.over {
  text-decoration: #00c853 overline underline;

.skip {
  text-decoration: #2962ff underline;
  text-decoration-skip: ink;

/* general styling */
pre {
  background-color: rgba(0, 0, 0, 0.04);
  border-radius: 3px;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  padding: 3px;

code {
  white-space: nowrap;

That’s all! hopefully, you have successfully created decorative text. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link