Chapter 2. HTML Values and Units

IN THIS CHAPTER

  • Basic Tag Attribute Format

  • Common Attributes

  • Text and Comments

  • Uniform Resource Indicators

  • Language and International Options

In the previous chapter you learned what markup language is and how it relates to HTML and the Web. Expanding on these basics, you can add attributes to your HTML tags to further control their effect on your documents.

Basic Tag Attribute Format

Most HTML tags support one or more attributes. These attributes are included in the opening tag using a standard format, as follows:

attribute_name="attribute_value"

For example, the border attribute is used with the <table> tag to control the width of the border in and around a table in the document. The border attribute resembles the following when actually included in the <table> tag:

<table border="1">

Pay close attention to the following rules regarding attributes:

  • Any attributes in an HTML tag need to appear after the HTML tag name.

  • The attribute name must be followed immediately by an equal sign (=).

  • The attribute value needs to come immediately after the equal sign.

  • The attribute value must always be enclosed in quotes, either single or double.

Note

In previous versions of HTML, some attributes—namely, those with default values—did not need to have a value associated with them. However, in HTML all attributes must have a value included inside the tag with their declaration. In short, you should always provide a value with tag attributes.

Several different types of values can be ...

Get HTML, XHTML, and CSS Bible, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.