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.
- wavy
- dashed
- double
- dotted
- 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.
*, *:before, *:after { box-sizing: border-box; margin: 0; padding: 0; } body { font: 1.4em/1.75 sans-serif; margin: 1em; } .cd__main{ 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 */ code, 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.
Similar Code Snippets:
I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences.
I truly enjoy what I’m doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.