[web] Making new xhtml tags?

Started by
14 comments, last by Rob Loach 19 years, 5 months ago
Is it possible to define new tags for xhtml? I have heard it can be done with xml modules. Is there any other way, like css or something? I am wanting to define my own html tags to do certain stuff for my cms. Like <cms_block></cms_block> that sets up the block div and ends the block div. Has anyone even attempted this also? [Edited by - jumpjumpjump on November 13, 2004 2:31:00 PM]
Advertisement
there are two ways to go about what you're thinking.

1. Use CSS to define the behavior/look of a tag. So you could have

code
{
display:block;
background-color:#ccc
}

that will make any <code></code> tags display as a block (like p tags) and have a gray background.

2. If you use an application server (ie. asp.net, php, coldfusion, etc), your CMS can store the specialized tags in the database. When it comes time to display your content, you can do a search and replace for your special tags and replace them with whatever you want.

-edit: also, if you put simply put special tags in your markup and use CSS to define their behavior, the page will not validate as xhtml. But if you don't care about that, then knock yourself out :-)
Hope that helps,
Joel Martinez
http://codecube.net
[twitter]joelmartinez[/twitter]
I use XML to do something similar which is then transformed into XHTML using XSL and combined with a CSS stylesheet to do this sort of thing.

So in my CMS, I can type something like <newsfeed id="demo" /> and it'll place the newsfeed where needed. The XSLT will sort out the conversion into div tags and apply the right style.
Would this work and validate and then define their behavior with css?
Edit: Something like this: http://www.w3.org/MarkUp/Guide/xhtml-m12n-tutorial/

Edit2:
joelmartinez: your site has sql injections: http://codecube.net/viewitem.asp?cc_catID=18&cc_typeID='4&catName=Code%20Bank

strip out the quotes and stuff before you perform your query.
Quote:Original post by jumpjumpjump
Would this work and validate and then define their behavior with css?
Edit: Something like this: http://www.w3.org/MarkUp/Guide/xhtml-m12n-tutorial/

Edit2:
joelmartinez: your site has sql injections: http://codecube.net/viewitem.asp?cc_catID=18&cc_typeID='4&catName=Code%20Bank

strip out the quotes and stuff before you perform your query.


ick injections
You can't add new elements to XHTML, that would not be right.

But you could define your own namespace which is NOT XHTML, and stick elements belonging to that schema into xhtml documents, and style them with CSS.

BUT there's no reason that any particular browser should or would support that.

But they probably will.

Also, you could confuse older / simpler browsers because they might interpret those elements as HTML, which of course they would not be.

I suppose the right thing to do for an XHTML browser is to ignore elements from namespaces it doesn't know what to do with.

Mark
Agreed, nor should you expect your browser to handle it. Do what you like server-side, as long as it's converted into standard XHTML (and styled using CSS) client-side there won't be an issue.
I just thought of something, since I am using smarty, I'll just write an extension for it so that it can parse my cms specific code. :)
Thanks for the help guys.
No problem .

I'd recommend doing it using the CSS. This way you could go:
// HTML<div id="good">This is good text!</div>// CSS#good {  font-size: small;}

You could change the style to anything you want. When you change the CSS, it'll change globally. No need to worry about smarty at all.
Rob Loach [Website] [Projects] [Contact]
I know, but this is for a custom block template language for the block system in my CMS.
I want it to be like this so no0bs can make blocks.
<cmsblock><blocktitle>Title</blocktitle><blockcontent>content wow</blockcontent></cmsblock>


So I am going to just write a smarty plugin that will parse the template and return the template with the tags replaced with their html.

This topic is closed to new replies.

Advertisement