By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,619 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,619 IT Pros & Developers. It's quick & easy.

style defining custom made tag: is this portable?: x {foo: bar} <x>Hello world</x>

P: n/a
Hi,

I am just starting to get familiar with all the ins and outs
of html.
I noticed that you can define a style, e.g.:

x {color: green; font-weight: bold}

and then use <x> and </x> tags in your body. How convenient!

Question is, is this actually allowed under the W3C spec of
the latest version HTML, and is it portable across all/majority
of browers?

I couldn't find this as such answered when googling.
Using Linux/Mozilla, btw.

Thanks for you time.

-- thisbe
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Els
Bauke Jan Douma wrote:
Hi,

I am just starting to get familiar with all the ins and
outs of html.
I noticed that you can define a style, e.g.:

x {color: green; font-weight: bold}

and then use <x> and </x> tags in your body. How
convenient!
It's called CSS.
http://www.w3.org/TR/2004/CR-CSS21-20040225/

And you can't just use <x>, you need to use real html
elements.
http://www.w3.org/TR/html4/index/elements.html
Question is, is this actually allowed under the W3C spec of
the latest version HTML, and is it portable across
all/majority of browers?


Portable, yes. But not all styles are supported in every
browser. Especially IE isn't completely standards compliant.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -
Jul 20 '05 #2

P: n/a
Bauke Jan Douma wrote:
x {color: green; font-weight: bold}

and then use <x> and </x> tags in your body.

Question is, is this actually allowed under the W3C spec of
the latest version HTML
No. (Although if you were using a custom XML language you could do this
(making sure you served it as something other then text/html)).
, and is it portable across all/majority of browers?


No.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 20 '05 #3

P: n/a
bj*****@xs1.xs4all.nl (Bauke Jan Douma) wrote in message news:<40***********************@news.xs4all.nl>...
I noticed that you can define a style, e.g.:

x {color: green; font-weight: bold}

and then use <x> and </x> tags in your body. How convenient!


This isn't permitted.

Don't mess with the tags in HTML. Use the set you were given and no
others.

If you _really_ want to do this, then switch to XHTML and use XML
namespacing. This is now perfectly valid (as XML), but it stretches
the boundaries of what's seen as acceptable HTML by most browsers and
validators. It'll give you problems.

The real way to do this is with compliant HTML, using the <span> and
<div> elements, but add a class attribute to them. You now have code
like this:

.x {color: green; font-weight: bold; }

<p>A paragraph with a <span class="x" >green</a> word.</p>
To make this work well, red the HTML specification and the DTD, and
get the distinction cleaqr in your mind about <span>, <div> and the
difference between block and inline elements.
Jul 20 '05 #4

P: n/a
Els
Andy Dingley wrote:
.x {color: green; font-weight: bold; }

<p>A paragraph with a <span class="x" >green</a>
word.</p>


Just swap that </a> for a </span> ;-)

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -
Jul 20 '05 #5

P: n/a
Els wrote:
Andy Dingley wrote:
.x {color: green; font-weight: bold; }

<p>A paragraph with a <span class="x" >green</a>
word.</p>


Just swap that </a> for a </span> ;-)


In fact, if that class is supposed to emphasise the word 'green' then this
is much better:

<p>A paragraph with a <strong class="x">green</strong> word.</p>
..x {color: green; font-weight: bold; }
(the font-weight is unnecessary here)

Or even

<p>A paragraph with a <strong>green</strong> word.</p>
strong {color: green; font-weight: bold; }

--
Matt
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.