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.

2
  • 1
    All valid css values are strings. Commented Jan 8, 2012 at 4:56
  • @kennebec Aren't integers also possible? -- That's what I had thought, but I assume you are right. Thanks for the information. Commented Jan 8, 2012 at 5:02

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

The attribute I am bothered with is, for example, loop attribute used in <audio>. This kind of attributes are supposed to be absent when you want it to be "false", so if I set it to something like loop=false, it is still recognized as true as long as the attribute is there. That is why I need to remove it instead of assigning false.
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 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.
Thanks for the quick reply, but I just posted another question: 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.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.