A question on the basics of HTML tags.

Discussion in 'HTML' started by Florent, Oct 20, 2004.

  1. Florent

    Florent Guest

    Hi,

    We are having a small discussion about tags in html.
    would I be right in saying that the ONLY allowed syntax is
    ....
    <my_tag attrib="name"> and </my_tag>
    ....
    To be more precise, I want to know,
    Is these legal html tags "<my_tag>" and "< my_tag >" or are some browsers
    forgiving when it comes to the above, (and for closing could I do "< /
    my_tag >"?).

    Because if both "<my_tag>" and "< my_tag >" are legal/accepted then how
    would I enter something like,
    ....
    <my_tag> Hello World this < is allowed in html </my_tag>
    ....
    or even an invalid "<" and more subtle case where it might look like a tag,
    (look for the "<is" with no space)
    ....
    <my_tag> Hello World this <is allowed in html </my_tag>
    ....
    Because if some browsers are been too lax then is this fair to say that the
    code above might be displayed one way in one browser and differently in
    another.

    Many thanks for your views. Would there be a site to dispute/verify my
    assumption?

    Florent
    --
    http://www.myoddweb.com
    http://www.myoddweb.com/forum
     
    Florent, Oct 20, 2004
    #1
    1. Advertising

  2. Florent

    Dylan Parry Guest

    As an authority on the subject, Florent proclaimed:

    > Is these legal html tags "<my_tag>" and "< my_tag >"


    According to the specs, no -- but that doesn't mean that a browser would
    treat them as invalid. The best case is to stick to the standards and use
    the former.

    > <my_tag> Hello World this < is allowed in html </my_tag>

    ^

    In this case you would replace the ambiguous "<" with "&lt;" which is the
    character code for the the less-than symbol.

    --
    Dylan Parry
    http://webpageworkshop.co.uk - FREE Web tutorials and references
     
    Dylan Parry, Oct 20, 2004
    #2
    1. Advertising

  3. Florent

    Steve Pugh Guest

    On Wed, 20 Oct 2004 11:59:28 +0100, Florent <>
    wrote:

    > We are having a small discussion about tags in html.
    > would I be right in saying that the ONLY allowed syntax is
    > ...
    > <my_tag attrib="name"> and </my_tag>
    > ...
    > To be more precise, I want to know,
    > Is these legal html tags "<my_tag>" and "< my_tag >" or are some browsers
    > forgiving when it comes to the above, (and for closing could I do "< /
    > my_tag >"?).


    The start of the element name must follow immediately after the <
    So < my_tag > is just text not a tag.

    You can have space after the element name and before the >
    So <my_tag > is fine.

    For closing tags if there is a space after the < then as with opening tags
    you have text not a tag. A space between the / and the element name is an
    error.
    Spaces after the tag name and before the > are fine.

    > Because if both "<my_tag>" and "< my_tag >" are legal/accepted


    They're both legal, but one is a tag and the other is text.

    > then how would I enter something like,
    > ...
    > <my_tag> Hello World this < is allowed in html </my_tag>


    You could leave it as it is or escape the < as &lt; Your choice.

    > or even an invalid "<" and more subtle case where it might look like a
    > tag,
    > (look for the "<is" with no space)
    > ...
    > <my_tag> Hello World this <is allowed in html </my_tag>


    This is different.
    As 'i' is a valid start charcter for an element name the < must be escaped
    as &lt; in this case.

    Steve
     
    Steve Pugh, Oct 20, 2004
    #3
  4. Florent

    Florent Guest

    >
    > The start of the element name must follow immediately after the <
    > So < my_tag > is just text not a tag.


    It makes sense, maybe I should test how browsers would view it.
    Is there a set of "official" rules or is it simply accepted?

    >
    > You can have space after the element name and before the >
    > So <my_tag > is fine.


    It also makes sense.

    >
    >> Because if both "<my_tag>" and "< my_tag >" are legal/accepted

    >
    > They're both legal, but one is a tag and the other is text.


    Yes, sorry I meant is, is the second one a legal tag.

    >> ...
    >> <my_tag> Hello World this <is allowed in html </my_tag>

    >
    > This is different.
    > As 'I is a valid start charcter for an element name the < must be escaped
    > as &lt; in this case.


    Yes but "<I>" is legal but how would/should "<I" be interpreted?
    following the rules and example above. the tag would become "<is allowed in
    html </my_tag>" where the tag is "is" with garbage inside as attributes and
    <my_tag> is never closed.

    >
    > Steve


    Florent

    --
    http://www.myoddweb.com
    http://www.myoddweb.com/forum
     
    Florent, Oct 20, 2004
    #4
  5. Florent

    Florent Guest

    "Dylan Parry" <> wrote in message
    news:p...
    > As an authority on the subject, Florent proclaimed:
    >
    >> Is these legal html tags "<my_tag>" and "< my_tag >"

    >
    > According to the specs, no -- but that doesn't mean that a browser would
    > treat them as invalid. The best case is to stick to the standards and use
    > the former.


    Are those specs freely available? if so where?

    >
    >> <my_tag> Hello World this < is allowed in html </my_tag>

    > ^
    >
    > In this case you would replace the ambiguous "<" with "&lt;" which is the
    > character code for the the less-than symbol.


    It might be ambiguous to rogue browsers but am I right in saying that
    according to the specs there is nothing wrong with it the way it is?

    >
    > --
    > Dylan Parry


    Florent

    --
    http://www.myoddweb.com
    http://www.myoddweb.com/forum
     
    Florent, Oct 20, 2004
    #5
  6. Florent

    Steve Pugh Guest

    On Wed, 20 Oct 2004 12:35:06 +0100, Florent <>
    wrote:

    >>
    >> The start of the element name must follow immediately after the <
    >> So < my_tag > is just text not a tag.

    >
    > It makes sense, maybe I should test how browsers would view it.


    I doubt you'll find many browsers getting this wrong.

    > Is there a set of "official" rules or is it simply accepted?


    The rules are those of SGML as used in the HTML specification.



    >>> <my_tag> Hello World this <is allowed in html </my_tag>

    >>
    >> This is different.
    >> As 'I is a valid start charcter for an element name the < must be
    >> escaped as &lt; in this case.

    >
    > Yes but "<I>" is legal but how would/should "<I" be interpreted?


    The above example has nothing to do with <i>. If it was <the then I would
    have said exactly the same thing with 't' instead of 'i' and there is no
    <t> element in HTML.

    > following the rules and example above. the tag would become "<is allowed
    > in html </my_tag>" where the tag is "is" with garbage inside as
    > attributes and <my_tag> is never closed.


    The </ marks the start of an end tag. So the
    "<is allowed in html" opening tag is never completed.

    Steve
     
    Steve Pugh, Oct 20, 2004
    #6
  7. Florent

    rf Guest

    Florent wrote

    > Are those specs freely available? if so where?


    You are kidding, are you not? You are posting to an HTML group and you don't
    know where the HTML specifications are?

    I will assume that you are new and you wish to learn... So, here you are:

    http://www.w3.org/TR/html4/

    Read all of it!


    Then read it again.


    Then when you have a question (which is likely as the specs are loose) come
    back :)

    --
    Cheers
    Richard.
     
    rf, Oct 20, 2004
    #7
  8. Florent

    brucie Guest

    In alt.html rf said:

    > Then when you have a question (which is likely as the specs are loose)


    i believe the polite term is "sexually free" not "loose". we don't want
    the kiddies picking up unsavory terminology do we.

    --


    v o i c e s
     
    brucie, Oct 20, 2004
    #8
  9. Florent

    rf Guest

    brucie wrote:

    > In alt.html rf said:


    > > Then when you have a question (which is likely as the specs are loose)


    > i believe the polite term is "sexually free" not "loose". we don't want
    > the kiddies picking up unsavory terminology do we.


    Hmmm... <looks at specs/>

    Property: The house your parents live in, you know, the place where you get
    your money and sometimes if you are real lucky the keys to the car.

    Attribute: What the owners of the Property try to instill in one. You know:
    If you have good attributes you will get a nice job in the Bank across the
    road.

    Element: Well, they make us learn about those things in physics class don't
    they. No use for a job in the Bank though.

    Tag: You're it!

    Rule: Enough said.

    --
    Cheers
    Richard.
     
    rf, Oct 20, 2004
    #9
  10. Florent

    Florent Guest

    >
    > You are kidding, are you not? You are posting to an HTML group and you
    > don't
    > know where the HTML specifications are?


    I didn't know it was a requirement for posting here.
    Are there any other obscure rules I should know in the hope of posting here
    again?

    >
    > I will assume that you are new and you wish to learn... So, here you are:


    No, I am not new, but thanks anyways.

    >
    > http://www.w3.org/TR/html4/
    >
    > Then when you have a question (which is likely as the specs are loose)
    > come
    > back :)


    So another basic rule for posting here is to already be an expert in html.
    Seen that you are posting here I will assume you are yourself an expert and
    that you know exactly where the answer to my OP would be in the document.

    >
    > --
    > Cheers
    > Richard.
    >


    Florent

    --
    http://www.myoddweb.com
    http://www.myoddweb.com/forum
     
    Florent, Oct 20, 2004
    #10
  11. Florent

    Sam Hughes Guest

    "Florent" <> wrote in
    news::

    >>
    >> You are kidding, are you not? You are posting to an HTML group and
    >> you don't
    >> know where the HTML specifications are?

    >
    > I didn't know it was a requirement for posting here.
    > Are there any other obscure rules I should know in the hope of posting
    > here again?


    You did pay your crystal ball tax, right?

    > So another basic rule for posting here is to already be an expert in
    > html. Seen that you are posting here I will assume you are yourself an
    > expert and that you know exactly where the answer to my OP would be in
    > the document.


    That is not a rule (and my sarcasm detector might be malfunctioning:
    forgive me).
     
    Sam Hughes, Oct 20, 2004
    #11
  12. Florent

    Neal Guest

    On Wed, 20 Oct 2004 11:59:28 +0100, Florent <>
    wrote:

    > Hi,
    >
    > We are having a small discussion about tags in html.
    > would I be right in saying that the ONLY allowed syntax is
    > ...
    > <my_tag attrib="name"> and </my_tag>


    Essentially, yes.

    > To be more precise, I want to know,
    > Is these legal html tags "<my_tag>" and "< my_tag >" or are some browsers
    > forgiving when it comes to the above, (and for closing could I do "< /
    > my_tag >"?).


    To be a valid tag there must be a legal character after <. Browsers may or
    may not be forgiving, depending on their conformance.

    > Because if both "<my_tag>" and "< my_tag >" are legal/accepted then how
    > would I enter something like,
    > ...
    > <my_tag> Hello World this < is allowed in html </my_tag>
    > ...
    > or even an invalid "<" and more subtle case where it might look like a
    > tag,
    > (look for the "<is" with no space)
    > ...
    > <my_tag> Hello World this <is allowed in html </my_tag>


    I never include < or > (or &) in HTML as text as a rule. If I need those
    characters I "escape" them with &lt; and &gt; (and &amp;) respectively.
    This is the safe route.

    Compare to attribute values. Sometimes you don't need to quote them, but
    it's never wrong to, and it's far easier to always quote than to memorize
    when you can leave the quotes out. Same here. There may well be times when
    < will work as text, but best to avoid the mess by using the other form.

    W3C links to this page for more info about SGML:
    [http://www.iso.org/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=16387]
     
    Neal, Oct 20, 2004
    #12
  13. Florent

    brucie Guest

    brucie, Oct 20, 2004
    #13
    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. Dean H. Saxe
    Replies:
    0
    Views:
    1,040
    Dean H. Saxe
    Jan 3, 2004
  2. Rob Nicholson
    Replies:
    3
    Views:
    752
    Rob Nicholson
    May 28, 2005
  3. Donald Firesmith

    html tags within meta tags allowed?

    Donald Firesmith, Jan 5, 2005, in forum: XML
    Replies:
    5
    Views:
    904
    Andy Dingley
    Jan 8, 2005
  4. Vik Rubenfeld

    Newbie Question on the Basics

    Vik Rubenfeld, Aug 17, 2007, in forum: Ruby
    Replies:
    1
    Views:
    81
    Gordon Thiesfeld
    Aug 17, 2007
  5. Luke
    Replies:
    22
    Views:
    232
    Lasse Reichstein Nielsen
    Sep 26, 2005
Loading...

Share This Page