×

How to create blinking text using CSS

The blinking effect is used in HTML and CSS to take the attraction towards a particular word or section. If you need such a blinking effect, we need to take the help of CSS.

CSS is the only language which is used for the creation of such type of effect without the help of JavaScript. The @keyframe rule is used for the design of such kind of blinking effect. We have to set the visibility to hidden. We are going to take the help of the extension web-kit for compatibility in all browsers.

Example 1

<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
.blink {
animation: blink-animation 1s steps(5, start) infinite;
-webkit-animation: blink-animation 1s steps(5, start) infinite;
}
@keyframes blink-animation {
to {
visibility: hidden;
}
}
@-webkit-keyframes blink-animation {
to {
visibility: hidden;
}
}
</style>
</head>
<body>
Welcome to <span class="blink">javaTpoint</span> text.
</body>
</html>

Output-

How to create blinking text using CSS

Example 2

<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
.blink {
width: 220px;
height: 50px;
background-color: #342ab8;
padding: 10px;
text-align: center;
line-height: 50px;
}
span {
font-size: 26px;
font-family: cursive;
color: #fff;
animation: blink 2s linear infinite;
}
@keyframes blink {
0% {
opacity: 0;
}
50% {
opacity: .5;
}
100% {
opacity: 1;
}
}
</style>
</head>
<body>
<div class="blink">
<span>javaTpoint</span>
</div>
</body>
</html>

Output-

How to create blinking text using CSS

Example 3

HTML Code-

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content=
	"width=device-width, initial-scale=1.0">
<title>Blinking Text</title>
</head>
<body>
<div>
	<h2>JavaTpoint</h2>
</div>
</body>
</html>

CSS code-

<style>
body{
margin: 0;
padding: 0;
}


div{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}


h2{
font-size: 5em;
font-family: serif;
color:#008000;
text-align: center;
animation: animate 1.5s linear infinite;
}


@keyframes animate{
0%{
	opacity: 0;
}
50%{
	opacity: 0.7;
}
100%{
	opacity: 0;
}
}
</style>

If we combine both HTML and CSS code, the final code is as follows:

<!DOCTYPE html>
<html lang="en">


<head>
	<meta charset="UTF-8">
	<meta name="viewport" content=
"width=device-width, initial-scale=1.0">


	<title>Blinking Text</title>


	<style>
body {
margin: 0;
padding: 0;
}


div {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}


h2 {
font-size: 5em;
font-family: serif;
color: #008000;
text-align: center;
animation: animate
1.5s linear infinite;
}


@keyframes animate {
0% {
opacity: 0;
}


50% {
opacity: 0.7;
}


100% {
opacity: 0;
}
}
	</style>
</head>


<body>
	<div>
<h2>javaTpoint</h2>
	</div>
</body>


</html>

Output-

How to create blinking text using CSS

Related Topics

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.

CSS Arrow

CSS Arrow The arrow of CSS is applied to insert an array with the tooltip. It can make a tooltip as any speech bubble. Also, this arrow can be illustrated in...

4 minutes read.

CSS Checkbox style

CSS Checkbox style: It is an element of HTML, which is used to get input from various users. It is difficult to style any checkbox. However, some elements make it...

6 minutes read.

Radial-gradient() CSS function

Radial-gradient() CSS function It defines a CSS in-built function, which produces a smooth transition among multiple colors. It is used to set any radial-gradient that is same as a background-image. This...

4 minutes read.

What is CSS

CSS stands for Cascading Style Sheet. It gives an additional style to the HTML document. A cascading style sheet is a language that is designed to define the document formatting...

3 minutes read.

CSS 3D Transform

Introduction To understand 3D transformation property of transform you need to first understand the difference between 2D and 3D transform. 2D transform is a CSS effect which transforms the elements according to...

6 minutes read.

CSS Background-blend-mode

Background-blend-mode The background-blend-mode property sets a blend mode of the component’s every background layer (color/image). It illustrates how the element background image blends well with the element background color. We can...

9 minutes read.

CSS Introduction

CSS stands for Cascading Style Sheet. It is a design language which is used to design the web pages. It was developed by Håkon Wium Lie on October 10, 1994. It provides...

1 minute read.

CSS Font-Size

A Cascading Style Sheet (CSS) is a simple design scripting language intended to simplify the process of making web pages more visually appealing with the kind of high-level formatting. Cascading...

3 minutes read.

CSS Margin

CSS Margin: The CSS margin property is employed to describe the space throughout the elements. It clears the range throughout the element. These properties do not have a background color...

2 minutes read.

CSS Sticky

CSS Sticky The position property in CSS is applied to set an element’s position. This property is also applied to position an element behind the other element. It is useful for...

1 minute read.

CSS z-index Property

CSS z-index: CSS z-index permits us to represent any visual hierarchy over a 3D plane that is the z-axis. This index can be applied to describe the positioned element’s stacking...

2 minutes read.

Combine Background Image with Gradient Overlay

With the help of CSS gradient, we can display smooth and straightforward transitions between two or more colours. We can add the background images by combining the gradient property with...

2 minutes read.

CSS Ellipsis

The CSS ellipsis kind of is the value that mostly is used by the property: text-overflow. Here, we will discuss the following: What is CSS Ellipsis? Syntax for CSS ellipsis How to...

3 minutes read.

CSS: nth-selector

CSS nth selector can be used to match an element according to its position regardless of its parent’s type. Here, n can be any number, formula, or a keyword. These selectors...

2 minutes read.

CSS Masking

CSS Masking The CSS mask property is applied to hide a component with the use of the masking or clipping an image at any specific point. The masking depicts the use...

3 minutes read.

CSS Comments

CSS Comments: Generally, comments in CSS are used to describe our code. Further, it will provide support to many users who are concerned with the code. Somewhat, these are ignored...

2 minutes read.

CSS Float

CSS Float: The float property of CSS is the positioning property. This property is applied to elements to push them either to left or right. It permits for wrapping facility...

4 minutes read.

CSS Word-spacing

Word-spacing The work-spacing property of CSS is applied to manage the space among the words. We can decrease or increase the space among the words by the use of this property. It...

3 minutes read.

CSS Transition

CSS Transition The transitions in CSS are influenced, included to modify the component from one design to another, without the use of the JavaScript or Flash. We should describe two of the...

2 minutes read.