Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
Which has more specificity between hidden attribute in HTML or display property in CSS? And how?

Also what is the best way to hide the elements from the DOM so that the attacker won't be able to change the css property or html attribute in order to access the element. I know we can use React or Angular to develop website and it is easier to hide or display elements. But I want to know in pure HTML & JS what is the best way?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Anyone can just use the browser console and find all elements with for example:

document.querySelectorAll('*');

It does not matter if elements are hidden with CSS.
Even if you encrypt your HTML you will have to decrypt it to show it to the browser. Then the above code still finds all the elements.

Any code you have can be deactivated by setting a breakpoint and rewriting it in-browser using the developer tools.

Even if you replace document.querySelectorAll and all like them with an empty function, developers can still just add jQuery or any DOM querying engine and find your elements that way.

Any code you can use to hide or show elements can just be executed using the browser console if someone spends the time understanding your code.
How else would you debug or test it?

Angular, Vue etc. does remove elements from the DOM but you should never expect this to be a security feature! A hacker can easily set a breakpoint anywhere in your code, inspect API results from the Network panel, go into the components' code to find out what HTML they would be rendering and much more I haven't started to mention.

To implement security you want to only have in the browser what the user needs to see.

There is no way around it.
DOM, stylings, scripts, assets, etc. can always be accessed using developer tools.

As for the question in your question title:

  • style attribute styles have a higher specificity than CSS from file (or style tags)
  • CSS from file (or style tags) with !important has higher specificity than styles from the style attribute
  • style attribute styles with !important have the highest specificty

So !important just overrides specificity if you want to look at it that way. Other than that you should read about CSS Specificity.

about 4 years ago · Juan Pablo Isaza Relatório

0

Both are same. If you store your value from html hidden or css hide. Anyone can find out them.

So if you are using html , js & css and want to pass value as hidden than disable developer tool and shortkey to open it by this way you can protect your data or else use any encryption method for that.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda