search
HomeWeb Front-endH5 TutorialGradient color text effect for each line of paragraph

This time I will bring you the gradient text effect of each line of paragraphs. What are the precautions for the gradient text effect of each line of paragraphs? The following is a practical case, let's take a look.

Today I saw an effect written in CSS on Codepen. Each line of text in a paragraph has a gradient effect. It’s not strange to implement a gradient fill effect for a single line of text or a single word, but it is a text gradient fill effect for each line of a paragraph. It is estimated that it will still make many people curious. If you are one of the curious ones, please read on to find out!

Target effect

Today’s target effect is to achieve the following effect, or to understand the tips for making this effect:

Gradient color text effect for each line of paragraph

Seeing the above effect, I think the first thing many people will think of is

background-clip:text, color:transparent and linear-gradient to complete. So is this the case?

How to complete the gradient effect of each line of text in a paragraph

Students who know CSS know it well, use:

background-image: linear-gradient(to right, deeppink, dodgerblue);
-webkit-background-clip: text;
color: transparent;
You can easily achieve a gradient fill effect for text. For example, the following example:

Gradient color text effect for each line of paragraph

Let’s do a small experiment. What will be the effect if the text is not a word or a single line but an entire paragraph?

Gradient color text effect for each line of paragraph

The effect seems to be perfect. If you change the gradient effect parameters, the gradient effect will be an oblique angle:

background-image: linear-gradient(135deg, deeppink, dodgerblue);
Look at the effects of the two:

Gradient color text effect for each line of paragraph

Look carefully, both The effect is still different. Let’s first look at the same size container (the size of the p element in this example is 765px * 165px). For two different gradient effects, let’s first look at the filling effect of to right:

Gradient color text effect for each line of paragraph

Let’s look at the filling effect of 135deg:

Gradient color text effect for each line of paragraph

Now that we are here, you may know what is different from the previous example? And also know what the reason is? If we want various gradients to have the same filling effect for each line of a paragraph, how should we achieve it? Before implementation, let’s briefly summarize:

Use to right or to left in linear-gradient, whether it is a single word, a single line of text, or multiple lines of text, the text filling effect will be the same. But for other gradient angle parameters, the effect of each line in a multi-line text fill will be different.

Back to the topic? How to achieve multiple rows and have the same effect regardless of the filling angle? There is a key attribute to achieve this effect:

box-decoration-break. To put it simply, the box-decoration-break attribute has two attribute values: slice and clone, and their corresponding effects are as follows:

is used in a paragraph, and its effects are as follows:

Gradient color text effect for each line of paragraph

Are we getting closer to our goal? Then use this attribute box-decoration-break:clone for our example:

background-image: linear-gradient(135deg, deeppink, dodgerblue);
background-clip: text;
-webkit-background-clip: text;
box-decoration-break: clone;
-webkit-box-decoration-break: clone;
color: transparent;
The effect is as follows:

Gradient color text effect for each line of paragraph

Let’s verify whether it matches ours Expected desired effect:

Gradient color text effect for each line of paragraph

Tips: box-decoration-break is applied to inline elements, and matched with the corresponding line-height to allow a certain spacing between lines.

Looking back, let’s see, using box-decoration-break is the difference between inline elements and block elements:

Gradient color text effect for each line of paragraph

Isn’t it very Perfect. If you like, try it yourself.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

APP listening return event processing in H5

##Front-end technology to implement text texture overlay

The above is the detailed content of Gradient color text effect for each line of paragraph. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
H5 and HTML5: Commonly Used Terms in Web DevelopmentH5 and HTML5: Commonly Used Terms in Web DevelopmentApr 13, 2025 am 12:01 AM

H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

What Does H5 Refer To? Exploring the ContextWhat Does H5 Refer To? Exploring the ContextApr 12, 2025 am 12:03 AM

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

H5: Tools, Frameworks, and Best PracticesH5: Tools, Frameworks, and Best PracticesApr 11, 2025 am 12:11 AM

The tools and frameworks that need to be mastered in H5 development include Vue.js, React and Webpack. 1.Vue.js is suitable for building user interfaces and supports component development. 2.React optimizes page rendering through virtual DOM, suitable for complex applications. 3.Webpack is used for module packaging and optimize resource loading.

The Legacy of HTML5: Understanding H5 in the PresentThe Legacy of HTML5: Understanding H5 in the PresentApr 10, 2025 am 09:28 AM

HTML5hassignificantlytransformedwebdevelopmentbyintroducingsemanticelements,enhancingmultimediasupport,andimprovingperformance.1)ItmadewebsitesmoreaccessibleandSEO-friendlywithsemanticelementslike,,and.2)HTML5introducednativeandtags,eliminatingthenee

H5 Code: Accessibility and Semantic HTMLH5 Code: Accessibility and Semantic HTMLApr 09, 2025 am 12:05 AM

H5 improves web page accessibility and SEO effects through semantic elements and ARIA attributes. 1. Use, etc. to organize the content structure and improve SEO. 2. ARIA attributes such as aria-label enhance accessibility, and assistive technology users can use web pages smoothly.

Is h5 same as HTML5?Is h5 same as HTML5?Apr 08, 2025 am 12:16 AM

"h5" and "HTML5" are the same in most cases, but they may have different meanings in certain specific scenarios. 1. "HTML5" is a W3C-defined standard that contains new tags and APIs. 2. "h5" is usually the abbreviation of HTML5, but in mobile development, it may refer to a framework based on HTML5. Understanding these differences helps to use these terms accurately in your project.

What is the function of H5?What is the function of H5?Apr 07, 2025 am 12:10 AM

H5, or HTML5, is the fifth version of HTML. It provides developers with a stronger tool set, making it easier to create complex web applications. The core functions of H5 include: 1) elements that allow drawing graphics and animations on web pages; 2) semantic tags such as, etc. to make the web page structure clear and conducive to SEO optimization; 3) new APIs such as GeolocationAPI support location-based services; 4) Cross-browser compatibility needs to be ensured through compatibility testing and Polyfill library.

How to do h5 linkHow to do h5 linkApr 06, 2025 pm 12:39 PM

How to create an H5 link? Determine the link target: Get the URL of the H5 page or application. Create HTML anchors: Use the <a> tag to create an anchor and specify the link target URL. Set link properties (optional): Set target, title, and onclick properties as needed. Add to webpage: Add HTML anchor code to the webpage where you want the link to appear.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools