name="value"
The quotes ( double style are the most common, but single style quotes are also al-
lowed) around the value are not necessary under HTML5, as long as the value doe sn’t
contain some restricted character (mostly =, >, or a space). That said, it is still a good
practice that you always use quotes. Your code will look clean er and more readable,
which in turn lessens the possibility of errors. Likewise, it is not necessary that you
use lower-case names and values, although it is recommended that you do so.
Some attributes do not have values. All that counts is their presence: they are either
present or not, similar to an electrical switch, wh ic h can be put in on o r off position .
That type of attribute is called a Boolean attribute after an English mathematician,
George Boole, the inventor of the so-ca lled Boolean log ic based on only two values.
Because Bo olean attributes have no value (the value is implied by their presence or
absence), we omit the equals sign as well:
name
There are often cases when an element has more than on e attribute. In that case the
attributes are separated by spaces.
If I confused you with all this theoretical talking, don’t worry. I will now show you
how this works in practice.
Maybe you’ve already heard about the character encoding. Basically, that’s a system
that tells you how each character of a given repertoir e is represented physically. In
a computer, this physical representation consists of a series o f ones and zeros, called
bits. Relax, I’m not going into more detail with this explanation. T he important thing
is that the browser mu st know what enc oding has bee n used to store the document
text so it can read it back and show it properly. If you don’t provide the encoding
informa tion to your markup, a browser will of cou rse try to g uess it, which may drive
it into an obscure security issue. You should provide this info rmation through the
charset (that’s short for character set) attribute of a <meta> element, assigning it the
value utf-8. Tod ay, more than half of all web pages are encoded in UTF-8 and
honestly, I don’t think you will ever need to use a character that is not in cluded in
UTF-8.
Let’s check if y ou followed me. Can you a dd a <meta> element containing a ch aracter
encoding attribute to our previous example without my help?
Maria: You didn’t tell us in which section to put it. Let me think
.... You said that the
content went into the <body> and all the other information in the <head>. Something
like the following code, perhaps?
<head>
<meta charset="utf-8">
<title>The Smallest HTML Document</title>
</head>
6 Meeting 1. Content and Structure