×

Create a 3D text effect using HTML and CSS

A3D text effect is a beautiful and attractive part of a webpage. As a web page developer, it is crucial to know how to create a 3D text effect with the help of HTML and CSS. The full form of HTML is HyperText Markup Language. The full form of CSS is Cascading Style Sheet. To create 3D text effect is one of the attractive, easy and simple methods.

Approach

This effect is designed by the text-shadow development. The main thing behind this article is to give the web page 3D look. 

HTML code-

In this portion, we give <h1> tag to the word we will provide 3D design.

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


<body>
<h1>javaTpoint</h1>
</body>


</html>

CSS code-

*,
*::before,
*::after {
 box-sizing: border-box;
}


:root {
 --color-primary: #f6aca2;
 --color-secondary: #f49b90;
 --color-tertiary: #f28b7d;
 --color-quaternary: #f07a6a;
 --color-quinary: #ee6352;
 /*
 --color-primary: #5192ED;
 --color-secondary: #69A1F0;
 --color-tertiary: #7EAEF2;
 --color-quaternary: #90BAF5;
 --color-quinary: #A2C4F5;
 */
}


body {
 min-height: 100vh;
 font-family: canada-type-gibson, sans-serif;
 font-weight: 300;
 font-size: 1.25rem;
 display: flex;
 flex-direction: column;
 justify-content: center;
 overflow: hidden;
 background-color: #eff8e2;
}


.content {
 display: flex;
 align-content: center;
 justify-content: center;
}


.text_shadows {
 text-shadow: 3px 3px 0 var(--color-secondary), 6px 6px 0 var(--color-tertiary),
 9px 9px var(--color-quaternary), 12px 12px 0 var(--color-quinary);
 font-family: bungee, sans-serif;
 font-weight: 400;
 text-transform: uppercase;
 font-size: calc(2rem + 5vw);
 text-align: center;
 margin: 0;
 color: var(--color-primary);
 //color: transparent;
 //background-color: white;
 //background-clip: text;
 animation: shadows 1.2s ease-in infinite, move 1.2s ease-in infinite;
 letter-spacing: 0.4rem;
}


@keyframes shadows {
 0% {
 text-shadow: none;
 }
 10% {
 text-shadow: 3px 3px 0 var(--color-secondary);
 }
 20% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary);
 }
 30% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary);
 }
 40% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary),
 12px 12px 0 var(--color-quinary);
 }
 50% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary),
 12px 12px 0 var(--color-quinary);
 }
 60% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary),
 12px 12px 0 var(--color-quinary);
 }
 70% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary);
 }
 80% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary);
 }
 90% {
 text-shadow: 3px 3px 0 var(--color-secondary);
 }
 100% {
 text-shadow: none;
 }
}


@keyframes move {
 0% {
 transform: translate(0px, 0px);
 }
 40% {
 transform: translate(-12px, -12px);
 }
 50% {
 transform: translate(-12px, -12px);
 }
 60% {
 transform: translate(-12px, -12px);
 }
 100% {
 transform: translate(0px, 0px);
 }
}

Output:

Create a 3D text effect using HTML and CSS

Example 2-

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>


<style media="screen">
body {
background-color: #444;
font-family: sans-serif;
}
div {
width: 800px;
height: 100px;
margin: 200px auto;
perspective: 1000px;
perspective-origin: 50% -200px;
}
h1 {
text-align: center;
text-transform: uppercase;
font-size: 4em;
letter-spacing: 0.1em;
color: #EEE;
animation: rotate 2s ease-in-out alternate infinite;
}
h1:before {
content: attr(data-shadow);
color: transparent;
text-shadow: 0 0 15px #111;
position: absolute;
z-index: -1;
margin: -0.1em 0 0 0;
animation: skew 2s ease-in-out alternate infinite;
transform-origin: bottom;
}
@keyframes rotate {
from {
transform: rotateY(-10deg);
text-shadow: 1px -1px #CCC,
2px -1px #BBB,
3px -2px #AAA,
4px -2px #999,
5px -3px #888,
6px -3px #777;
}
to {
transform: rotateY(10deg);
text-shadow: -1px -1px #CCC,
-2px -1px #BBB,
-3px -2px #AAA,
-4px -2px #999,
-5px -3px #888,
-6px -3px #777;
}
}
@keyframes skew {
from {
transform: scaleY(0.3) skewX(-15deg);
}
to {
transform: scaleY(0.3) skewX(-20deg);
}
}


</style>
</head>
<body>
<div>
<h1 data-shadow="3D Text Effect">
3D Text Effect
</h1>
</div>


</body>
</html>

Output:

Create a 3D text effect using HTML and CSS

Related Topics

Difference between HTML and CSS

HTML HTML stands for HyperText Markup Language and is used to create web pages and websites and web applications, which means we can create static web pages. Html is a scripting...

3 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 Outline

CSS Outline: This CSS property is quite similar to the border property of CSS. It eases us to design an additional border around the element to obtain visual attention. The...

4 minutes read.

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.

How to change font size in CSS

How to change font size in CSS? Font Size: - Users may attract attention to content on a website page in various ways. One element in a sentence can be highlighted. You...

5 minutes read.

How to change the font in CSS

How to change the font in CSS? Professionals can't deny typefaces — how users organize and style text — if we want to completely customize the website's design. One may wish...

4 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.

Create a 3D text effect using HTML and CSS

A3D text effect is a beautiful and attractive part of a webpage. As a web page developer, it is crucial to know how to create a 3D text effect with...

3 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 Letter-spacing

CSS Letter-spacing: Letter-spacing attribute is applied to manage the space among all letters within the block or element of the text. This property sets the behavior of the spacing between...

2 minutes read.

Is CSS a programming language?

 A programming language is a set of grammatical rules and a vocabulary for commanding a machine to accomplish specified tasks. High-level languages like BASIC, C, C++, COBOL, Java, FORTRAN, Ada...

4 minutes read.

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...

2 minutes read.

How to resize an image in CSS

How to resize an image in CSS? The resize image attribute is used in responsive web design to resize images to fit within the div container automatically. The resize image attribute...

3 minutes read.

Internal CSS

What is CSS? CSS stands for Cascading Style Sheet.CSS is used to apply styling the HTML elements.With CSS user can add or change color, font-size and font-family. It also helps user...

4 minutes read.

CSS Inline

What is CSS? CSS is an acronym for Cascading Style Sheets. CSS is the language that we use to style an HTML document. It specifies how HTML components should appear. CSS...

4 minutes read.

CSS User Interface

Introduction User Interface can be defined as series of visual elements like screens, buttons, forms that help the user interact with the software application or hardware device. CSS User Interface allows the...

6 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.

Untitled Reusable Block

  ...

1 minute read.

What is Bootstrap CSS?

Bootstrap: - Bootstrap is a CSS framework that is free to use and is used for the front-end development of the website in a faster and easier way. Bootstrap was released as...

3 minutes read.

CSS Background

CSS Background The properties of CSS background are applied to describe the effects of background on the element. Here are five properties of background that affects various elements of HTML: Background-colorBackground-imageBackground-repeatBackground-attachment Background-position Background-color The color of the background...

7 minutes read.