w3c / w3c/csswg-drafts

[css-pseudo] [css-content] add new type of content that clones the text within the node

Open
#8,938 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-content-3
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

I suggest a new keyword to be added to the content property which duplicates the textContent DOM property, instead of developers having to define the same text twice, when a pseudo-element is needed to have the same text content as its node.

I suggest to name it text. I was considering contents but it might imply it will use innerHTML as content, instead of the textContent property.

<p class='foo'>Hello world</p>
.foo {
  position: relative;
}

.foo {
  content: text; /* same as manually typing "Hello world" */
  position: absolute;
  z-index: -1;
}

Such use-uses are very common, to achieve visual effects and what not, for example:

https://jsbin.com/livamiwadu/edit?html,css,output

where the text has an outer glow using a filter property, but the text itself is still crisp.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the linked MDN documentation for the CSS content property and the issue's examples of pseudo-element text duplication. Determine whether a text keyword matching the node's textContent is appropriate, then document the agreed syntax and behavior in the relevant CSSWG draft.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.