The Basic Form of HTML Attributes
All HTML attributes have a
name and a
value. And they take the following form:
Please note that the
value is always contained within a pair of quote marks. You can use a pair of double quotes (
"value") or a pair single quotes (
'value'). I usually use double quotes.
The Proper Placement and Spacing of HTML Attributes
Attributes are placed within the opening tag just after the tag’s keyword. A tag can contain more than one attribute.
At least one space must separate the tag’s keyword and the first attribute. At least one space must separate each of the attributes from each other. A space is not required between the last attribute and the right angle bracket (>) that completes the opening tag.
Some Examples of HTML Attributes
Below are some examples of some tags with attributes. Don’t worry about what the tags or attributes mean or do at this point. I just want you to see some examples of what HTML attributes look like:
(src & id)
If the browser encounters an attribute it doesn’t recognize, it ignores it. Usually, this means you misspelled the attribute’s name or provided a value that doesn’t make any sense.
Well, I think that’s enough about HTML attributes — at least for now. Next we’ll talk about how you shouldn’t overlap HTML tags.