Is it valid?

Discussion in 'HTML' started by Samuël van Laere, Nov 1, 2003.

  1. I just wonder if it is ok to have a empty tag?
    For example:
    <div id="header"></div>

    It validates fine so that isn't a problem.


    --
    With regards,
    Samuël van Laere
    the Netherlands
    Samuël van Laere, Nov 1, 2003
    #1
    1. Advertising

  2. Samuël van Laere wrote:
    > I just wonder if it is ok to have a empty tag?
    > For example:
    > <div id="header"></div>


    I often wonder at the purpose of empty elements.

    > It validates fine so that isn't a problem.


    May I enquire why one would want such a thing?

    --
    William Tasso - http://WilliamTasso.com
    William Tasso, Nov 1, 2003
    #2
    1. Advertising

  3. Samuël van Laere

    Eric Bohlman Guest

    "Samuël van Laere" <> wrote in
    news:aJUob.43163$:

    > I just wonder if it is ok to have a empty tag?
    > For example:
    > <div id="header"></div>
    >
    > It validates fine so that isn't a problem.


    Since it validates fine (as it should; the content model for div is
    "(%flow;)*" which explicitly allows empty content), it's definitely valid,
    which was the question you asked in your Subject: line. If you're asking
    whether it's harmful, I'm not aware of any circumstances where it is.
    However, if you're going to set properties like background color, height,
    and width on it in order to get colored areas or the like, IIRC some
    browsers will refuse to acknowledge its existence until you put *some*
    content (just an &nbsp; will usually work) in it. IOW,

    div#header {background-color: red; height: 10px; width: 100%;}

    might not give you a 10-pixel high red bar unless you put some content in.
    Eric Bohlman, Nov 1, 2003
    #3
  4. "William Tasso" <> schreef in bericht
    news:bo18e8$1660k8$-berlin.de...
    > Samuël van Laere wrote:
    > > I just wonder if it is ok to have a empty tag?
    > > For example:
    > > <div id="header"></div>

    >
    > I often wonder at the purpose of empty elements.
    >
    > > It validates fine so that isn't a problem.

    >
    > May I enquire why one would want such a thing?
    >
    > --
    > William Tasso - http://WilliamTasso.com
    >
    >


    There isn't a purpose for empty elements, the best next thing to overcome
    that is using &nbsp;
    In my case i use <div id="header"></div> to display a logo in the header, i
    don't want any text with it.
    But perhaps you have a better idea?
    http://www.fortron.net



    --
    With regards,
    Samuël van Laere
    the Netherlands
    Samuël van Laere, Nov 2, 2003
    #4
  5. Samuël van Laere

    Kris Guest

    In article <bo2thu$1pa7$>,
    "Samuël van Laere" <> wrote:

    > In my case i use <div id="header"></div> to display a logo in the header, i
    > don't want any text with it.


    Why not put an <img> inside there that gets hidden by CSS for screen
    display and shown on print-out as that nice company logo on white? Can
    also contain some nice ALTernative text to represent your company to
    search engines that (naturally) do not see your logo.

    --
    Kris
    erlands (nl)
    Kris, Nov 2, 2003
    #5
  6. While the city slept, William Tasso <> feverishly typed:

    > Samuël van Laere wrote:
    >> I just wonder if it is ok to have a empty tag?
    >> For example:
    >> <div id="header"></div>

    >
    > I often wonder at the purpose of empty elements.
    >
    >> It validates fine so that isn't a problem.

    >
    > May I enquire why one would want such a thing?


    Well... you never know when it might come in handy? ;-)

    Cheers,
    Nige

    --
    Nigel Moss.

    Email address is not valid. . Take the dog out!
    http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
    In the land of the blind, the one-eyed man is very, very busy!
    nice.guy.nige, Nov 2, 2003
    #6
  7. "Kris" <> schreef in bericht
    news:4all.nl...
    > In article <bo2thu$1pa7$>,
    > "Samuël van Laere" <> wrote:
    >
    > > In my case i use <div id="header"></div> to display a logo in the

    header, i
    > > don't want any text with it.

    >
    > Why not put an <img> inside there that gets hidden by CSS for screen
    > display and shown on print-out as that nice company logo on white? Can
    > also contain some nice ALTernative text to represent your company to
    > search engines that (naturally) do not see your logo.
    >
    > --
    > Kris
    > erlands (nl)


    Thanks for your comments Kris.

    I'm not sure if it will be a improvement, i use a different logo for some
    styles.
    I haven't used any <img> tags so far.
    Right now i use &nbsp; for the element and that works.

    Besides how do i hide a <img> anyway?


    --
    With regards,
    Samuël van Laere
    the Netherlands
    Samuël van Laere, Nov 2, 2003
    #7
  8. Samukl van Laere wrote:

    > Besides how do i hide a <img> anyway?


    In your stylesheet, assuming you're still using <div id="header"> (try
    <h1>, that's probably a better fit):

    @media screen {
    #header img { display: none; }
    }

    If you replace your DIV with an H1, similarly replace #header with h1.

    (Fix your sig separator, eh?)
    Owen Jacobson, Nov 3, 2003
    #8
    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. Aschel Kritsos

    Valid file types

    Aschel Kritsos, Nov 11, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    582
  2. Ajit
    Replies:
    1
    Views:
    3,581
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  3. CT

    vbc is not valid command

    CT, Oct 30, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    2,815
  4. Pial
    Replies:
    6
    Views:
    52,357
    Nassos
    Apr 28, 2005
  5. MM
    Replies:
    3
    Views:
    432
    Kai Harrekilde-Petersen
    Jun 19, 2004
Loading...

Share This Page