Introduction to CSS strikethrough
The CSS strikethrough is nothing, but whenever we enabled the text-decoration property in the file to create the text data in the css with the strikethrough effect. This is also one of the animation effects in the css with the help of some default values like line-through is one of the default value its mentioned by the text-decoration property. We used this as the inline or with any other style sheets with the same effects inline and outline features are enabled mainly in the <p> tag is nothing but the selector means we want to format the html elements.
Syntax and Parameters
The CSS codes are written with the html page using a style tag; we can follow some rules and syntax for customized web pages more attractiveness. We use text format type as all the css properties and their attributes.
<html>
<head>
<style>
.first
{
Background-color:;
Color:;
Font-size:;
---some default css properties,attributes and their values based on the requirements----
}
</style>
</head>
<body>
<p style=”text-decoration:line-through;”>
</p>
--some html codes---
</body>
</html>
The above codes are the basic codes for the css strikethrough values in the property of the text-decoration; it may vary if the user changes the values based on their needs. The parameter here is we can specify the values in the attributes as well as called the values in the codes.
How does strikethrough work in CSS?
In the CSS style codes, we used a lot of attributes, properties with default values. It will be both texts, number, special characters, etc.; using these types of values, we can enable the particular property of their css attributes to make the presentation with more attractiveness. We can use the css color codes in the html text-based elements by using some default html tags, ID or Some built-in classes. When we use css strikethrough in html tag-based elements <h1> is one of the default and most widely used in the html codes for making them as color and presentation of the css styles also it helps any elements in the CSS.<h1> mostly we used in the <head> tag in the html because <style> also declare and initialized in there so <h1> heading line probably we used there in the web pages.
Next, we can use the css strikethrough with the help of the span element in the html web pages the same way we used <h1> heading tag,<p> tag. Still, the element is provided in the html is giving it in default ID; these ids are declared in the heading part of the style code; the ID can be any used any styled the same as used in the html tags. Still, the important point is the id value should start with the special character like the ‘#’ symbol; after that, we can use any number of formats like alphabets, numbers etc. We can use strike-through text with both inline and outline elements in css with the help of span elements; it’s one of the methods for adding the strikethrough in the text-decoration property of the css style sheet.It also followed the above two methods, but the difference is without the ‘#’ symbol.’ Symbol in the css code.
The prefix value should start compulsory in dot operator, or else the css codes are not used in the html web pages the presentation is not shown on the screen.Apart from that the same classes are declared in the <style> tag the same class names are called in the <h1> tag element is <h1 class=””></h1> <span> classes and <p style=””> elements. These are the ways which have been declared and initialized the strikethrough text values of the css property called text-decoration elements in the html web pages.
Moreover, the css used a different set of properties and related with the text, colors, videos etc. and based upon some datas are changed in these attributes “color, direction,letter-spacing,word-spacing,text-indent,text-align,text-decoration,text-transform,white-spaces and text-shadow” these are some default properties which has been used in the style codes for each properties, and it has their own features of the CSS.
Example of CSS strikethrough
Here are the following example mention below
Example #1
Code:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-decoration: line-through;
}
h2 {
text-decoration: overline;
}
h3 {
text-decoration: underline overline;
}
h4 {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Welcome To My Domain</h1>
<h2>Welcome To My Domain</h2>
<h3>Welcome To My Domain</h3>
<h4>Welcome To My Domain</h4>
</body>
</html>
Output:
Example #2
Code:
<!DOCTYPE html>
<html>
<head>
<title>Welcome To My Domain</title>
<style>
.first {
text-decoration: underline overline;
padding: 12px;
width: 73%;
margin: 2 auto;
background-color:"#ffffff";
text-align: center;
color: rgb(105%, 0%, 0%);
border-radius: 1 2 52px 53px;
border: 2px yellow;
}
.second{
text-decoration: underline;
margin: 12px;
padding: 13px;
color: hsla(0, 105%, 50%, 0.5);
border: 3px blue;
}
.third{
text-decoration: overline;
width: 122px;
display: inline-block;
background-color: blue;
}
.four{
text-decoration: line-through;
text-align: right;
}
.five{
text-align: center;
}
.six{
text-align: left;
}
.eleven {
width: 83%;
margin: 2 auto;
padding: 23px;
background: green;
}
.sam {
position: absolute;
right: 3px;
width: 303px;
background-color: yellow;
}
</style>
</head>
<body>
<div class="first">Siva</div>
<div class="second">Raman</div>
<div class="third">Arun</div>
<p style="color: #ffffff; background-color: #ff0000">Namer is: red, background-color is : blue</p>
<div class="five">Sam</div>
</body>
</html>
Output:
Example #3
Code:
<!DOCTYPE html>
<html>
<head>
<title>Welcome To My Domain</title>
<style>
.first {
text-decoration: underline overline;
padding: 12px;
width: 73%;
margin: 2 auto;
background-color:"#ffffff";
text-align: center;
color: rgb(105%, 0%, 0%);
border-radius: 1 2 52px 53px;
border: 2px yellow;
}
.second{
text-decoration: underline;
margin: 12px;
padding: 13px;
color: hsla(0, 105%, 50%, 0.5);
border: 3px blue;
}
.third{
text-decoration: overline;
width: 122px;
display: inline-block;
background-color: blue;
}
.eleven {
text-decoration: line-through;
width: 83%;
margin: 2 auto;
padding: 23px;
background: green;
}
.sam {
position: absolute;
right: 3px;
width: 303px;
background-color: yellow;
}
</style>
</head>
<body>
<div class="first">Siva</div>
<div class="second">Raman</div>
<div class="third">Arun</div>
<div class="eleven">
<img src="first.jpg" alt="centered image" />
</div>
</body>
</html>
Output:
Conclusion
The strikethrough text is one of the important property because it is used in the CSS text-decoration property with text-based features. It is placed in the web pages with the correct positions; it does not affect the other contents like images and animations.
Recommended Articles
This is a guide to CSS strikethrough. Here we discuss How does strikethrough work in CSS and Examples along with the codes and outputs. You may also have a look at the following articles to learn more –