Custom html element names

Discussion in 'HTML' started by emf, May 5, 2013.

  1. emf

    emf Guest

    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

    --
    Natal Transits Calculator
    https://files.nyu.edu/emf202/public/jv/nataltransits.html
     
    emf, May 5, 2013
    #1
    1. Advertising

  2. emf

    richard Guest

    On Sat, 04 May 2013 20:59:42 -0400, emf wrote:

    > 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.
     
    richard, May 5, 2013
    #2
    1. Advertising

  3. 2013-05-05 3:59, emf wrote:

    > 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
    <script> element at the start of the <head>).

    > 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.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, May 5, 2013
    #3
  4. On Sat, 04 May 2013 20:59:42 -0400, emf wrote:

    > 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 ...

    --
    Denis McMahon,
     
    Denis McMahon, May 5, 2013
    #4
  5. emf

    emf Guest

    On 2013-05-05 03:44 Jukka K. Korpela wrote:
    > 2013-05-05 3:59, emf wrote:
    >
    >> 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
    > <script> element at the start of the <head>).
    >
    >> 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.


    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

    --
    It ain't THAT, babe! - A radical reinterpretation
    https://files.nyu.edu/emf202/public/bd/itaintmebabe.html
     
    emf, May 6, 2013
    #5
  6. On Mon, 06 May 2013 04:46:49 -0400, emf wrote:

    > 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.

    --
    Denis McMahon,
     
    Denis McMahon, May 6, 2013
    #6
  7. 2013-05-06 11:46, emf wrote:

    > 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?

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, May 6, 2013
    #7
  8. emf

    Tim Streater Guest

    In article <km7snq$jq2$>,
    Denis McMahon <> wrote:

    > On Mon, 06 May 2013 04:46:49 -0400, emf wrote:
    >
    > > 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.


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

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
     
    Tim Streater, May 6, 2013
    #8
  9. 2013-05-06 12:22, Denis McMahon wrote:

    > 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.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, May 6, 2013
    #9
  10. emf

    emf Guest

    On 2013-05-06 05:29 Jukka K. Korpela wrote:
    > 2013-05-06 11:46, emf wrote:
    >
    >> 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?


    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

    --
    Date Calculator with all-purpose JS code
    https://files.nyu.edu/emf202/public/js/dateCalculator.html
     
    emf, May 7, 2013
    #10
  11. emf

    dorayme Guest

    In article <kmabpg$pu0$>, emf <>
    wrote:

    > 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.

    --
    dorayme
     
    dorayme, May 7, 2013
    #11
  12. On Mon, 06 May 2013 10:35:46 +0100, Tim Streater wrote:

    > In article <km7snq$jq2$>,
    > Denis McMahon <> wrote:


    >> On Mon, 06 May 2013 04:46:49 -0400, emf wrote:


    >> > My pages are valid html 5


    >> There is no HTML 5 standard yet ...


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


    Yes, exactly my point, and much more succinctly stated. ;)

    --
    Denis McMahon,
     
    Denis McMahon, May 7, 2013
    #12
  13. On Mon, 06 May 2013 12:39:54 +0300, Jukka K. Korpela wrote:

    > 2013-05-06 12:22, Denis McMahon wrote:


    >> 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


    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. ;)

    --
    Denis McMahon,
     
    Denis McMahon, May 7, 2013
    #13
  14. 2013-05-07 18:22, Denis McMahon wrote:

    >>> 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

    >
    > 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).

    >> 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.


    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).

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, May 7, 2013
    #14
  15. On 2013-05-06, emf wrote:
    > On 2013-05-05 03:44 Jukka K. Korpela wrote:
    >> 2013-05-05 3:59, emf wrote:
    >>
    >>> 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
    >> <script> element at the start of the <head>).
    >>
    >>> 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.

    >
    > 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?


    For what it's worth:
    <http://cfajohnson.com/shell/bsg/w3cvalidhtml5.jpg>

    --
    Chris F.A. Johnson
    <http://torontowebdesign.cfaj.ca/>
     
    Chris F.A. Johnson, May 8, 2013
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carl
    Replies:
    0
    Views:
    539
  2. Matt
    Replies:
    2
    Views:
    886
    Ben Edgington
    Oct 12, 2004
  3. Replies:
    2
    Views:
    529
  4. HANM
    Replies:
    2
    Views:
    762
    Joseph Kesselman
    Jan 29, 2008
  5. mortb
    Replies:
    5
    Views:
    156
    mortb
    May 24, 2004
Loading...

Share This Page