Tag Attributes

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

Some work, some don't. It depends partly on what browser you are using.

Tag Attributes

A tag attribute is information contained within a tag. For example the previous pages have discussed attribues of the <span> tag. For example <span style="color:red"> gives the style attribute the value "color:red". The values should always be enclosed in quotations marks. Usually HTML will work if you skip the quote marks, but you may get into trouble later on.

Officially, there should be no spaces on either side of the = sign, although, again, most browsers are forgiving.

Only the first tag of a pair of tags contains attributes. Most tags have several potential attributes, but you don't have to use them. If you don't use an attribute, you get its default value. You can list more than one attribute within the tag (as above).

QUESTION 18:

If you specify an attribute that a tag does not support, what (do you think) will happen? For example,

<p color="red"> Some Paragraph<p>