A Strikethrough Within A Box In An Inline Css

CSS Programming

Have you ever come across a webpage where you saw a strikethrough text within a box, and wondered how it was done? Well, you’re in luck because in this article, I’m going to dive deep into the world of inline CSS and show you how to create a strikethrough within a box using this powerful technique.

Inline CSS refers to the practice of applying CSS styles directly within the HTML tags. While it’s generally recommended to use external or internal CSS for better code organization and maintainability, there are certain scenarios where inline CSS can come in handy, such as when you need to apply styles to a specific element quickly.

To create a strikethrough within a box using inline CSS, we can leverage the text-decoration property along with the border property. Let’s break down the process step by step.

Step 1: Creating the Box

To start, we need to create the box that will contain our text. We can achieve this by setting the display property of the element to inline-block and specifying the desired dimensions using the width and height properties. For example:

<div style="display: inline-block; width: 200px; height: 100px; border: 1px solid black;"></div>

This code snippet creates a box with a width of 200 pixels, a height of 100 pixels, and a black solid border. Feel free to adjust the dimensions and border styles to suit your preference.

Step 2: Adding the Strikethrough Text

Now that we have our box, let’s add some text inside it and apply the strikethrough effect. We can do this by using the <span> element and applying the text-decoration: line-through style to it. Here’s an example:

<div style="display: inline-block; width: 200px; height: 100px; border: 1px solid black;">
<span style="text-decoration: line-through;">This text is crossed out</span>

With this code, we have a box with the text “This text is crossed out” displayed inside it, and the text is styled with a strikethrough effect.

Step 3: Fine-tuning the Design

Now that we have the basic structure in place, we can further enhance the design by adjusting additional CSS properties. For example, we can change the background color of the box, add padding or margins, or even apply different font styles to the text. The possibilities are endless!


Creating a strikethrough within a box using inline CSS is a powerful technique that allows you to quickly add visual emphasis to your text. While it’s important to note that inline CSS should be used sparingly and only when necessary, it can be a useful tool in certain situations where you need to make quick style modifications.

Remember, experimenting and playing around with different CSS properties is key to mastering the art of web development. So go ahead, give it a try, and let your creativity shine!