O'Reilly logo

HTML, XHTML, and CSS Bible, Fourth Edition by Steven M. Schafer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required