HTML | Attributes

html attributes

Tag Attributes:

Tags support one or more attributes. These attributes are included in

attribute_name=”attribute_value”

<p align=”2″>

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

html id

The id attribute effectively assigns a unique identifier to a tag. For example, if you usea <table> to contain value, you might use the id attribute to name the table type:

<table id=”type”>
<code description goes here>
</table>

html class

Classes are similar to IDs in that they help identify tags in the document for use by other methods. However, unlike IDs, which should be unique, classes can (and should) be applied across several tags in your document.

<table class=”type”>
<code description goes here>
</table>

As with the id attribute, the class attribute doesn’t directly affect the tag to which it is added. What the class attribute does do is link the tag to CSS styles that also reference that specific class. To completely understand the link between the two — HTML tags using classes, and styles referencing those classes — you must understand CSS and its methods for accessing class-coded styles. However, keep classes in mind as you code your basic HTML so you can adequately incorporate them.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s