Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:18:25+00:00 2026-05-27T16:18:25+00:00

In essence what I’m trying to do is create a CSS style that can

  • 0

In essence what I’m trying to do is create a CSS style that can use the values of custom tag attributes as their values. I’ve read about the “attr()” function and it seems to work only in the content property of :before/:after selectors. Basically I’d like to do something like the following:

HTML

<span fgprop="#ff0000">Some Text</span>
<span fgprop="#00ff00">Other</span>

CSS

span {
    color : attr(fgprop);
}

The alternative to accomplish this, which I’m using now,is to use jQuery css() to set the color on each span with its fgprop attr value, but that seems very clunky since this approach won’t automatically react to changes in the fgprop property. CSS seems the best place for this as its a presentation only level transformation.

Is there a way to do this? (Right now I’m only targeting webkit, so some kind of -webkit- specific extension would work for my use case, if that matters). Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:18:25+00:00Added an answer on May 27, 2026 at 4:18 pm

    Isn’t this situation exactly what inline styles are for:

    <span style="color:#ff0000">Some Text</span>
    <span style="color:#00ff00">Other</span>
    

    If you’re going to specify the colours as attributes on individual elements anyway why overcomplicate it by having your stylesheet try to refer back to an fgprop attribute? A style attribute is just as easy to generate server-side, and just as easy to update client-side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a web-based tool for my company that, in essence,
I have a MySQL table that's being updated very frequently. In essence, I'm trying
The essence of my problem is that I can't write to a file in
Our SharePoint site has a couple of broad groups that use it. In essence
I have a need for some kind of information that is in essence static.
Slightly strange question, but hopefully someone can help. In essence, if the time was
I've written a usercontrol that, in essence, is a palette of widgets. When the
I have a question regarding jQuery. I have multiple images that are, in essence,
We're building a custom keyboard with the essence of the following code. - (void)viewDidLoad
I'm implementing an algorithm that, in essence, is a series of matrix-matrix multiplications like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.