HTML and XHTML - Lesson 5
Back to Lesson 1, Lesson 2, Lesson 3, Lesson 4
Some tags like the anchor tags have variables. This variable specified an extra bit of information for that tag to use. For example, the horizontal rule tag <hr />
can have a width variable:
Code:
<hr width="50%" />
Displays as:
Another example is the align variable that can be applied within the paragraph tag, <p>
.
For example:
Code:
<p align="right"> This paragraph will be aligned to the right side. </p>
Displays as:
This paragraph will be aligned to the right side.
HTML Variables are common in XHTML 1.0 and earlier. However, newer versions of HTML such as XHTML 1.1 and the upcoming XHTML 2.0 will not allow most HTML variables. Instead, CSS variables will be used.
I will teach you about CSS in another set of tutorials, but for now I will repeat the above examples with CSS variables in place of the HTML ones.
Code:
<hr style="width: 50%;" />
Displays as:
Code:
<p style="text-align: right;"> This paragraph will be aligned to the right side. </p>
Displays as:
This paragraph will be aligned to the right side.