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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:59:30+00:00 2026-05-28T13:59:30+00:00

Introduction elem.hidden is a new property that allows to hide elements and detect whether

  • 0

Introduction

elem.hidden is a new property that allows to hide elements and detect whether they are hidden.

The browser support isn’t great so I want to shim it. If I were to shim this property what should it be shimmed to in terms of setting a CSS property through elem.style.

Naive implementation of Shim

Object.defineProperty(HTMLElement.prototype, "hidden", {
  get: function get() {
    return this.style.<???>;
  },
  set: function set(v) {
    this.style.<???> = v ? <???> : <???>
  },
  configurable: true
});

Question

  • Should it set elem.style.display to "none" or <original value> ?
  • Should it set elem.style.visibility to "hidden" or "visible" ?
  • 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-28T13:59:31+00:00Added an answer on May 28, 2026 at 1:59 pm

    Browsers are required to implement the hidden attribute as [hidden] { display:none }

    See Boris Zbarsky’s answer to Force browser to ignore HTML 5 features, and the subsequent comments.

    Note that this is done via the user-agent style sheet, so it has a very low specificity, and is easily overridden by a more specific style, even those that don’t mention the hidden attribute.

    Although I think this is a terrible way to implement the hidden attribute, those are the rules. The nearest you can get to that behaviour is to put [hidden] { display:none } as near as you can to the very start of the first stylesheet on your HTML page, rather than applying directly to the style property of the element, where it will have a very high specificity.

    In terms of the element property, the HTML5 spec says “The hidden IDL attribute must reflect the content attribute of the same name.”, so that’s the only thing you should be adding via Object.defineProperty. However, kennebec’s comment that Object.defineProperty isn’t much more widely supported is probably valid.

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

Sidebar

Related Questions

Introduction Google chrome has a feature that allows you to create shortcuts to web
Introduction I have been so annoyed by applications that have a startup dialog which
every introduction and sample that I can find seems to use GLUT or some
Introduction I'm relatively new to C++. I went through all the basic stuff and
INTRODUCTION : I have a function(callback) that receives a object as an argument, inside
In Introduction to algorithms, 3rd edition exercise 24.3-5 wants an example that this is
Sorry for the verbose introduction that follows. I need insight from someone knowing P/Invoke
Introduction: I think Nape is a relatively new engine so some of you may
Introduction I've a question about something that I think it can become a little
Introduction I just thought of a new design pattern. I'm wondering if it exists,

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.