0

In CSS3, is there any attribute that takes false or null value? I suppose and expect not, but wanted to make sure.

I am writing a javascript code (related to ajax interaction) that sets or removes an attribute to/from some DOM object. The function takes an attribute name and its value as the arguments, and I am thinking that, if the value turns out to be false or null, then removeAttribute() function should be called, and otherwise, the attribute should be assigned with that value. If there is a style attribute that possibly takes false or null value, then I cannot do that, so I wanted to make sure.

sawa
  • 165,429
  • 45
  • 277
  • 381

2 Answers2

1

No, there is no attribute that takes false or null. However, I am pretty sure you can create your property without any visual impact.

blake305
  • 2,196
  • 3
  • 23
  • 52
  • The attribute I am bothered with is, for example, `loop` attribute used in ` – sawa Jan 08 '12 at 04:48
  • Actually, I tested it now, and if I set a value as `false`, it does indeed seem to be recognized as `false`. I will be asking another question to make sure about this point. – sawa Jan 08 '12 at 06:03
  • @sawa `loop=false` remains true unless the entire `loop` attribute is removed. Basically, the presence of just `loop` is what a tag needs to do something else. You need to use something like jQuery to remove the entier `loop` attribute (or at least that's what I would do). Now, if you set a different undefined attribute to false, then you are able to recognize it as false. – blake305 Jan 08 '12 at 06:08
  • Thanks for the quick reply, but I just posted another question: http://stackoverflow.com/questions/8775782 about the same time you commented back. I am with javascript, and I did `loop=false`, and that seems to have effect in stopping the loop of the audio play back. Maybe what you say is right, and this might be just a peculiar thing about Google Chorome. I will also see what others will say. Thanks for the help. – sawa Jan 08 '12 at 06:16
1

No. Even ones like speak-header which have only two possible values can still accept the special value inherit.

Mike Samuel
  • 118,113
  • 30
  • 216
  • 245