What are Boleani attributes?

Asked

Viewed 233 times

1

I would like to know what are these boleani attributes of HTML.
and how to understand this question of true or false ?

1 answer

3

Before understanding the boolean attributes in HTML it is essential to understand how boolean logic works. Within Boolean logic one can classify things or phenomena as true or false. An example:

  • Is Jonas Souza male? Answer: True
  • Is number 8 greater than number 5? Answer: True
  • Is Brazil a country located in the northern hemisphere? Answer: False

Note that all these questions have only two possible answers: yes or no. In this way, by making an analogy, Boolean logic would be like what popular wisdom calls "8 or 80" or "is or is not".

Now let’s look at the context of HTML. In HTML the presence of an attribute is already sufficient for it to be considered "true", just as its absence means that this attribute receives the value "false". The example below shows how attributes can be used in HTML5:

<audio src="BeeGees.mp3" controls>
</audio>

Note that the attribute "Controls" appears without the assignment command, that is, its presence already indicates that this attribute receives the value "true". If you wanted this attribute to be "false", simply remove it from the "audio" tag".

This way, whenever you want an attribute to receive "true" value, just put it in the tag, when you want it to be "false" just don’t declare it.

More information: http://www.maujor.com/blog/2011/09/24/atributos-booleanos/

(The code snippet used as an example was extracted from this link)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.