Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
Do browsers assure that if an inline css property has not been set, the value of "element.style.property" will always be a empty string?

For example:

<xxx id="myid" ...></xxx>

If no code or nobody sets the inline css properties of element "xxx", then document.getElementById("myid").style.property always equals ""?

Do w3c standards or all browsers assure it?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

On Blink based browsers, it seems to always set it to an empty string.

MDN recommends clearing them by setting them to null, which then isn't an empty string, but upon testing this in a blink based browser, it seems to reset to an empty string. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style

On some browsers, when a CSS property hasn't been set, it is literally undefined, which is quite different from null or "" (an empty string).

You can force some consistency between all browsers and updated values by coercing to an empty string.

document.getElementById("myid").style.property || ""

Edit - New properties

CSS is rapidly changing, with new properties appearing frequently. As such, it got me thinking, what happens in blink based browsers with unrecognised properties.

The answer is not consistent with known properties, and instead, they are undefined if not set. Equally these can be set to null.

I would recommend using falsy checks when appropriate to solve this problem.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda