Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom XHTML tags.. works but won't validate

Status
Not open for further replies.

Warthog32

Programmer
Mar 2, 2008
3
Hi,

I'm trying to re-write my website into XHTML with CSS, where previously it was quirks mode transitional HTML.

I'm just learning XHTML and ran across some examples that define custom tags, which are defined with CSS.

For example, I tried:

<TBL>
<ROW>
<CELL>
cell1
</CELL>
<CELL2>
cell2
</CELL2>
</ROW>
</TBL>

Where my CSS looks like:

TBL {
display: table;
}

ROW {
display: table-row;
}

CELL {
display: table-cell;
}

CELL2 {
display: table-cell;
}

This all seems to display correctly on browsers with XHTML support, and I love it since it makes the XHTML so concise and clean.

However, I can't get my page to validate (using the w3.org validator). It complains about each element with an error such as:

Error Line 41, Column 4: element "TBL" undefined.

Is there a way to properly "declare" these elements, other than doing so in the CSS? This all seems to work nicely, and so seems to be supported by the language, but is there something I'm missing?

Thanks!
 
In HTML, there is no <tbl> element. There's a <table>, which it appears you're trying to implement.

Lee
 
Thanks, I'm very familiar with HTML. I'm talking about XHTML (note the X), in which I'm trying to use custom entities.

Can anyone very familiar with XHTML help?
 
In all XHTML doctypes (the ones you're trying to validate against) there are only standard HTML elements defined. If you want to validate your page against these standard doctypes (available on the W3 website), then you will not be able to create new elements. You can however create your own doctype, link the doctype declaration to that doctype and have all elements you want defined there. That wouldn't be any of the real flavours of XHTML though.

I think you have confused XHTML with XML, where you actually define your own elements.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
You could try posting in forum426 to find tools that will validate an XML document (which is what your custom XHTML document would be) against a DTD or XML Schema. I don't really see what benefit you get from these non-standard elements, especially given the potential pitfalls of browsers not understanding them.

Personally, whenever I use XML documents to store and structure data behind the scenes, I pre-process them server-side so that browsers never see anything that isn't standard (X)HTML. That way you get the best of both worlds.

As an example, take a look at . The XML file at is rendered into two different (and wholly standard) XHTML tables.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks for the detailed replies. I guess I misunderstood the capabilities of XHTML.

I was largely thinking that XHTML was intended for taking XML data and allowing you to plop it almost verbatim into an XHTML document, and then define the visual formatting of that data with CSS.

Obviously that's not the case, and it looks like I'll have to have some rendering code to translate it into XHTML, like Chris Hunt has done.

As a side note, i was also hoping XHTML would basically allow a cleaner "HTML" file, by avoiding the need to define different class="x" attributes, and have the class be rolled up into the entity type. But again, this doesn't seem to be the case.

Thanks again
Warthog
 
As a side note, i was also hoping XHTML would basically allow a cleaner "HTML" file, by avoiding the need to define different class="x" attributes, and have the class be rolled up into the entity type. But again, this doesn't seem to be the case.
Do you mean you wanted to apply css to a certain type of element? If so, you can e.g
Code:
div {backgorund-colo:red;}
This would make all div tags have a red background.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top