HTML and CSS Reference
In-Depth Information
• A more complete discussion of behaviors, and built-in Internet Explorer behaviors
in particular, can be found at the MSDN site online (http://msdn.microsoft.com),
but you should note that, for security concerns, some behaviors have been removed
or modified over time.
• Behaviors are often bound to made-up elements when used, but this is not required.
binding
This property defines a relationship between bound elements(s) and some code or content.
Generally, it is used to associate some scripting to various elements in a document.
Syntax
binding: none | url(
bindingfile
)
where
bindingfile
is some technology such as XBL to add content or associate markup with
script code.
Example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
behavior and binding Example
</title>
<style type="text/css">
#clickable {behavior: url(hello.htc); -moz-binding: url(hello.xml);
binding: url(hello.xml);}
</style>
</head>
<body>
<p>
Just a regular paragraph.
</p>
<p id="clickable">
I'm special click me.
</p>
<p>
Just a regular paragraph.
</p>
</body>
</html>
The bound XBL file (hello.xml) looks like this:
<?xml version="1.0" encoding="utf-8"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="hello">
<handlers>
<handler event="click" action=
"alert('Hello world from the bound XBL')" />
</handlers>
</binding>
</bindings>