views:

23

answers:

1

Hi!

How can I add new tags to the xhtml document without making the markup 'invalid'?

for eg:

instead of <span class="time"> I'd like to use <time>. Is this possible? because I've seen a facebook app do something like this.

+1  A: 

You need to declare a new namespace for your invented elements:

<html xmlns:foo="urn:my-namespace">
...
<foo:time>...</foo:time>

or

<html>
...
<time xmlns="urn:my-namespace">...</time>

Of course, this isn't going to make an ounce of sense to your browser but I presume you have good reasons to want to do this.

x0n
actually I just want to make the code smaller and more intuitive :)Is this a bad idea?
Alex
nope, not at all. :)
x0n
It's not really a bad idea... but I doubt it'll work as expected in most browsers. Also, the `time` element (and many others) is available in HTML5. If you're not gearing up to use that already, you should be soon.
You