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 818405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:08:53+00:00 2026-05-15T02:08:53+00:00

Assume I have the following CSS: div { -my-foo: 42; } Can I later

  • 0

Assume I have the following CSS:

div {
    -my-foo: 42;
}

Can I later in JavaScript somehow know what the value of the -my-foo CSS property is for a given div?

  • 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-15T02:08:53+00:00Added an answer on May 15, 2026 at 2:08 am

    I don’t think you can access invalid property names, at least it doesn’t work in Chrome or Firefox for me. The CSSStyleDeclaration simply skips the invalid property. For the given CSS:

    div {
        width: 100px;
        -my-foo: 25px;
    }
    

    style:CSSStyleDeclaration object contains only the following keys:

    0: width
    cssText: "width: 100px"
    length: 1
    

    However, interestingly this is what the DOM-Level-2 Style spec says:

    While an implementation may not recognize all CSS properties within a CSS declaration block, it is expected to provide access to all specified properties in the style sheet through the CSSStyleDeclaration interface.

    implying that the CSSStyleDeclaration object ought to have listed the -my-foo property in the above example. Maybe there is some browser out there which supports it.

    The code I used for testing is at http://jsfiddle.net/q2nRJ/1/.

    Note: You can always DIY by parsing the raw text. For example:

    document.getElementsByTagName("style")[0].innerText
    

    but that seems like a lot of work to me, and not knowing your reasons for doing this, I can’t say if a better alternate for your problem exists.

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

Sidebar

Related Questions

Assume I have the following style table, col1 col2 and col3 have same value
Let's assume I have the following file structure: data.py foo = [] bar =
I hope you can help... Let's assume I have following XML: <data> <token> <sessionId>12345</sessionId>
I have the following html code : <div class=submit><input type=button name=getResult value=Get Comments class=sbutton
Let's say we have the following schema: root/ application/ -public/ index.php css/ img/ javascript/
Let's assume we have following models: from django.db import models class Foo(models.Model): name =
Assume I have the following: <input type=text> <div id=listofstuff> <div class=anitem> <span class=item name>Dog</span>
Assume I have the following tables: TABLE: foo - foo_id (PK) TABLE: tag -
I have the following (simplified) HTML structure <td> <DIV class=t-numerictextbox> <DIV class=t-formatted-value>$0.00</DIV> <INPUT id=MyObj_PropertyName
I have the following HTML / CSS: <table> <tr> <td> <div> <pre> <code> This

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.