is there any "SEO-friendly" way to show a page title like below?

Text duplication background

It's easy to implement with an HTML code like this:

<h2>Sample Title</h2>
<span class="shadow">Sample Title</span>

But isn't it bad for SEO, since it looks just like a duplicate content?

A css trick like h2::after { content: "Sample Title" } would work but I call the content dynamically from backend and I don't want to include a style tag inside the body.

  • If no style tag, perhaps inline css then? <h2 style="content: 'Sample Title';">Sample Title</h2>. Then you can use a blanket style in your external css to color and position it. May 6, 2022 at 18:05
  • Ahmet, I would suggest to avoid using the word duplicate in questions ... people not reading carefully may think it is a duplicate question. But, I think you found a use case. You seem to have a skill at finding use cases. May 8, 2022 at 23:46

2 Answers 2


After some researches and inspirations I finally found the right solution for my case.

Solution with a custom attribute:

 h2::after { content: attr(data-content); ... }


<h2 data-content="The Title">The Title</h2>

Solution with inline css:

 h2::after { content: var(--title); ... }


<h2 style="--title: The Title">The Title</h2>

As you see it prints the dynamically inserted content without duplicating it or touching the stylesheet.

Just some CSS knowledge and logic.. :)


Ahmet, you should be given a ranking boost by google merely for your due-diligence. But unfortunately they don't give a due-diligence boost.

One copy of text is not going to push you into the situation where google thinks you are keyword stuffing. They understand there are use cases like for example decorative text, where words may repeat.

One such use case is colored text, where multiple font glyph contain the different colors so the text is repeated (overlaying a diffent glyph of the same letters) for each color overlay. In this use case duplication is required.

1> One option is to use an image, which could be an svg giving a lot of decorative options.

2> Another is to use a canvas giving a lot of decorative options.

But these two options may not be as flexible to change content or in responsive layout.

3> use javascript ... not entirely ignored but will not to be confused with keyword stuffing.

If I am to assume you are going to have 8 or so copies of text "span"s to create a 3d effect of coming out of the page. And as you are using class, maybe more than one title using the effect ... Javascript may be the best option.

Note: I'm claiming special use for inline javascript for this case, I know people don't like inline javascript -- in this case it is to allow content to be added to the page.

.shadow {
   color:red; // example style not 3d

<div class="addeffect">
<h2 >Sample Title</h2>

elements = document.getElementsByClassName("addeffect")
text = elements[0].innerText; // special use case -- see note below.

var span = document.createElement("SPAN");
span.innerText = text;

// note this is special use inline on each heading so removing the class will advance to next element.
// instead could be coded once on page instead but as a new class is dynamically added ...
// So usage could change to once per page. Hence getElementById not used intentionally.



<div class="addeffect">
<h2 >New Title Just added</h2>

<!-- run same script here for new title and it will not effect prior title -->

This could be a function loaded normally into the page and then called from the script used to add the new content for to the page. In this case I don't know if that is an option. If it is ... then it is best that all javascript is in the same location instead of needing to look in different locations. Hence people don't like inline javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.