The Wayback Machine - https://web.archive.org/web/20081006082842/http://www.webreference.com/html/tutorial2/6.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

An Introduction to Element Attributes

Developer News
Microsoft Shows Some Ankle With Visual Studio
Gentoo Linux Cancels Distribution
It's Official: Windows 7 at PDC, WinHEC

In the previous tutorial we introduced the concept of elements and how HTML documents are made up of them, and how they can be nested. Elements identify a piece of the document as having certain meaning: the P element denotes a paragraph, the H1 element denotes a first-level heading and so on. Sometimes elements have other semantics as well, and that's where attributes come in.

Attribute Syntax

Attributes are written in an element's start-tag. They are separated by whitespace, and consist of a name and a value, separated by an equals sign. Let's take an example:

<SELECT SIZE="4" NAME="foo">
...
</SELECT>

The above is a SELECT element, which I haven't told you about, so don't worry about what it does yet. It has a start-tag and an end-tag, and some content which I'm omitting here.

It also has two attributes: A SIZE attribute which has the value of 4, and a NAME attribute which has the value of foo. What attributes mean depends on the type of element. Each element type has a list of possible set of attributes, and each attribute takes a certain kind of value. A SELECT element can have various attributes, one of which is SIZE, which accepts numerical values. It can also accept a NAME attribute that accepts text strings.

Note that both attribute values above are quoted using double quotes. You can quote attributes using either single or double quotes (single quotes are useful when the value itself contains double quotes), and it is recommended that you do so. It is not necessary, however, if the attribute values consist only of letters, digits, or the hyphen (-) and period (.) characters. To avoid confusion, however, it's better if you get used to quoting everything.

Boolean Attributes

Some attributes are used only to turn an element's specific behavior on or off. Such attributes are called boolean attributes. Boolean attributes only need to have a name. For instance, the following OPTION element (again, one you don't know about yet), has a VALUE attribute with the value option1 and has the boolean attribute SELECTED set.

<OPTION VALUE="option1" SELECTED>Option 1</OPTION>

Technically, there is an equivalent syntax for boolean attributes that sets their value as equal to their name. For example, the above is equivalent to this:

<OPTION VALUE="option1" SELECTED="SELECTED">Option 1</OPTION>

Some older user agents don't recognize this syntax, and there's no reason to do it in the first place anyway. But I'm merely mentioning this for the sake of completeness.

That's all the theoretical background you'll need for quite a while now. So now it's time to introduce the Anchor element.

Front Page12345678

http://www.internet.com

Produced by Stephanos Piperoglou


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
Controllers: Programming Application Logic - Part 2 · How to Use JavaScript to Validate Form Data · Controllers: Programming Application Logic
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Sprint Launches Mobile WiMAX Network · Albatron Downsizes with the KI780G Mini-ITX Motherboard · Can't Find a Wi-Fi Network? Make Your Own.


All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/html/tutorial2/6.html
Created: June 11, 1998
Revised: June 11, 1998

Morty Proxy This is a proxified and sanitized view of the page, visit original site.