Custom html element names

E

emf

It suddenly crossed my mind that it might be possible to create your own
html elements to replace <span>, and define them in CSS.

So I tried it in one of my first webpages:

https://files.nyu.edu/emf202/public/bd/warprayer.html

Since still I have a rather limited number of webpages, sometimes I feel
going back and revising and updating my old webpages' code. This one
needs more revising (it has mistakes in the image tags), but for now
what I did was create 2 new elements <prayer> and <angel> to replace
classes (<span class="prayer"> and <span class="angel">).

It works in FF but not in IE, so I'll be reverting to the <span> code
shortly. For a brief moment it seemed to me a pretty good idea
though!... But before re-revising the code, I'd like to hear more
experienced programmers' opinions on this. What do you think?

Thanks,

emf
 
R

richard

It suddenly crossed my mind that it might be possible to create your own
html elements to replace <span>, and define them in CSS.

So I tried it in one of my first webpages:

https://files.nyu.edu/emf202/public/bd/warprayer.html

Since still I have a rather limited number of webpages, sometimes I feel
going back and revising and updating my old webpages' code. This one
needs more revising (it has mistakes in the image tags), but for now
what I did was create 2 new elements <prayer> and <angel> to replace
classes (<span class="prayer"> and <span class="angel">).

It works in FF but not in IE, so I'll be reverting to the <span> code
shortly. For a brief moment it seemed to me a pretty good idea
though!... But before re-revising the code, I'd like to hear more
experienced programmers' opinions on this. What do you think?

Thanks,

emf

That's one thing XML is for.
XML allows you to use your own tags.
 
J

Jukka K. Korpela

It suddenly crossed my mind that it might be possible to create your own
html elements to replace <span>, and define them in CSS.

You cannot define elements in CSS. All you can do in CSS is to make
presentation suggestions on the rendering of elements. If that's what
you mean by "define them in CSS", yes, you can do that, with the usual
CSS caveats ( http://www.cs.tut.fi/~jkorpela/css-caveats.html ).
It works in FF but not in IE,

It works in IE 9 and newer. In older versions, you custom tags are
effectively ignored so that they cannot be styled. There's a partial fix
to this: "introduce" your custom elements this way:

<script>
document.createElement('foo');
document.createElement('bar');
</script>

before any style sheet or reference to a style sheet (i.e., put the
But before re-revising the code, I'd like to hear more
experienced programmers' opinions on this. What do you think?

There's not much to be said about the programming side of the matter
(the JavaScript code above is trivial, though if you have many custom
tags, you can make it shorter by writing a loop).

On the authoring side, here's my summary (abridged from
http://www.cs.tut.fi/~jkorpela/pragmatic-html.html8 ):
- you can't add functionality to custom elements, except by JavaScript
- in non-CSS rendering, presentation is as if the tags were not there
- some day some browser might start recognizing "foo" as a defined
element, and then you're in trouble (you can minimize the risk by using
cryptic tag names, but what's the point then?)
- validators and checkers will report the tags as errors, and then you
have difficulties in working with the real errors.
 
D

Denis McMahon

It suddenly crossed my mind that it might be possible to create your own
html elements to replace <span>, and define them in CSS.

So I tried it in one of my first webpages:

You're not quite doing what you think you're doing, and you're also
relying on how browsers handle and apply css to unrecognised elements,
which isn't guaranteed to be consistent across browsers or between
browser versions.

Generally, most browsers will ignore tags they don't recognise, including
attributes of those tags, but show the child nodes of those tags (whether
they're textnodes or elements).

Generally, browsers will apply css to nodes xml style.

However, it's never going to be a good idea to invent your own html tag
soup with any w3c dtd that relies on either of these behaviours.

There's nothing to stop you creating your own xml with your own dtds and
stylesheets. Browsers may even display this as you want ...
 
E

emf

You cannot define elements in CSS. All you can do in CSS is to make
presentation suggestions on the rendering of elements. If that's what
you mean by "define them in CSS", yes, you can do that, with the usual
CSS caveats ( http://www.cs.tut.fi/~jkorpela/css-caveats.html ).


It works in IE 9 and newer. In older versions, you custom tags are
effectively ignored so that they cannot be styled. There's a partial fix
to this: "introduce" your custom elements this way:

<script>
document.createElement('foo');
document.createElement('bar');
</script>

before any style sheet or reference to a style sheet (i.e., put the


There's not much to be said about the programming side of the matter
(the JavaScript code above is trivial, though if you have many custom
tags, you can make it shorter by writing a loop).

On the authoring side, here's my summary (abridged from
http://www.cs.tut.fi/~jkorpela/pragmatic-html.html8 ):
- you can't add functionality to custom elements, except by JavaScript
- in non-CSS rendering, presentation is as if the tags were not there
- some day some browser might start recognizing "foo" as a defined
element, and then you're in trouble (you can minimize the risk by using
cryptic tag names, but what's the point then?)
- validators and checkers will report the tags as errors, and then you
have difficulties in working with the real errors.

OK, it was just an idea. The
document.createElement('foo');

seems an interesting possible idea for the future.

The webpage was corrected and now validates for HTML5. But I couldn't
fin a "Valid HTML5" icon; I used the HTML 4.01 for now. Why don't they
have one?

emf
 
D

Denis McMahon

The webpage was corrected and now validates for HTML5. But I couldn't
fin a "Valid HTML5" icon; I used the HTML 4.01 for now. Why don't they
have one?

There is no HTML 5 standard yet. What you've validated against is a
proposed standard. The final standard may be different in a way that
makes your page invalid.
 
J

Jukka K. Korpela

The webpage was corrected and now validates for HTML5. But I couldn't
fin a "Valid HTML5" icon; I used the HTML 4.01 for now. Why don't they
have one?

Maybe they read my rant against such icons and admitted that I am right:
http://www.cs.tut.fi/~jkorpela/html/validation.html#icon

Seriously, I think they just realized that using such icon would be
disproportionately absurd in the case of *experimental* validation
against a *draft* (an unspecified draft at that). Both the validator
itself and the draft(s) used may and will change without prior notice
(and without posterior notice), so what would be the point of using an
icon just because your page happened to "validate" at one specific
moment of time?
 
T

Tim Streater

Denis McMahon said:
There is no HTML 5 standard yet. What you've validated against is a
proposed standard. The final standard may be different in a way that
makes your page invalid.

In other words, such icons are a stupid waste of time.
 
J

Jukka K. Korpela

There is no HTML 5 standard yet. What you've validated against is a
proposed standard.

No, W3C HTML5 is still at the "Candidate Recommendation" stage; next
year, it is expected to become "Proposed Recommendation" and then
"Recommendation". It will most probably never become a standard in any
other meaning than W3C Recommendation.

The W3C working group has already decided to make changes to HTML5, so
HTML5 CR does not reflect even working group consensus.

Besides, it has not been disclosed what the validator is really
validating against. It could be WHATWG Living HTML, or W3C HTML 5.1
Nightly, or even something somewhat different.
 
E

emf

Maybe they read my rant against such icons and admitted that I am right:
http://www.cs.tut.fi/~jkorpela/html/validation.html#icon

Seriously, I think they just realized that using such icon would be
disproportionately absurd in the case of *experimental* validation
against a *draft* (an unspecified draft at that). Both the validator
itself and the draft(s) used may and will change without prior notice
(and without posterior notice), so what would be the point of using an
icon just because your page happened to "validate" at one specific
moment of time?

Well, in this case at the very least those icons provide an easy way and
a reminder for the author, that is me, to recheck the page whenever in
the future I will think about it.

emf
 
D

dorayme

emf <[email protected]> said:
Well, in this case at the very least those icons provide an easy way and
a reminder for the author, that is me, to recheck the page whenever in
the future I will think about it.

You can easily provide for a link to check without need for a
provided-by-others icon. You can make the link simply textual, you can
make your own pic.
 
D

Denis McMahon

2013-05-06 12:22, Denis McMahon wrote:
No, W3C HTML5 is still at the "Candidate Recommendation" stage

Technicalities of language, although I grant that there are those like
the pointy eared one[1] who seem to consider that getting such
technicalities precisely correct is more important than conveying the
fundamental meaning of those technicalities.

In this case, I would suggest that the important point is that:

Whatever the state is of the current documentation of what forms a valid
html 5 document, it is not that of a formal standard.
Besides, it has not been disclosed what the validator is really
validating against. It could be WHATWG Living HTML, or W3C HTML 5.1
Nightly, or even something somewhat different.

Which reinforces again the point I was trying to make, and which Tim put
so succinctly - namely that any such validation is meaningless and thus
pointless.

[1] If you don't know who I mean, you should probably be thankful. ;)
 
J

Jukka K. Korpela

Technicalities of language,

Not really; a Proposed Recommendation would be essentially closer to
Recommendation, mostly just waiting for a seal of approval, whereas
Candidate Recommendation will probably still change (though we expect
the changes to be relatively small, such as possible omissions of
features marked as being at risk).
Whatever the state is of the current documentation of what forms a valid
html 5 document, it is not that of a formal standard.

That is true, but it does not quite hit the nail: HTML5 will most
probably never become a formal standard (but it is expected to be a
recommendation by the W3C, an industry consortium).
Which reinforces again the point I was trying to make, and which Tim put
so succinctly - namely that any such validation is meaningless and thus
pointless.

That would be a bit too far. HTML5 validation is useful to people who
sufficiently understand what it is and make some educated guesses too.
To other people, it might be really confusing.

The usefulness of HTML5 validation is seriously limited by its
evangelistic agenda. Even though HTML5 CR defines e.g. the <marquee>
element in detail, you cannot use HTML5 validators to check that you
have used it according to the definition. The validators are so eager at
sending an error message about the <marquee> element in the first place
(as "obsolete") that they do not check its attributes.

But still, when you use only elements and attributes that are accepted
by the authors of HTML5, the validators are helpful in analyzing whether
you have made syntactic mistakes with them.

The purpose of validation is to get error messages and warnings that
might be helpful. If you use validation to get an icon of approval, you
are misguided even if the validation process is technically correct and
well-defined (what HMTL5 validation isn't).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top