HTML validation question

Discussion in 'Mac Help/Tips' started by xjohn, May 8, 2003.

  1. xjohn macrumors regular

    Joined:
    Jan 6, 2003
    Location:
    Beijing
    #1
    I'm just getting started publishing a web page, and am just starting out learning HTML.

    I've been trying to get my web page to validate for HTML 4.01 Transitional, using the W3C validator, but there are a couple of errors that I can't figure out. I'm pretty sure I'm missing something silly.

    If someone html-savvy would be willing to check out my page and tell me why the following two errors keep showing up in the validator, I would be very grateful (and I'm pretty sure my page would validate!).

    1. "Line 6, column 68: character data is not allowed here
    ...ontent-type" content="text/html; charset=utf-8" />"

    (I really can't figure this one out. It's right at the beginning of the header of my document.)

    2. "Line 63, column 3: end tag for element "P" which is not open (explain...).
    </p>"

    (I've looked at the code many times, and I can't see why this error is showing up (repeatedly--for each entry of the weblog). I really think my elements are nested correctly!)

    Anyway, it would be great if someone could point out where I'm going wrong here. I'd also appreciate any other feedback on the site. The layout's a bit sparse, and I'm not quite happy with it yet, so I'd appreciate any advice from design-savvy Macrumors members. ;)

    Thanks,
    John
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    1) In your page header your META tags are XHTML not HTML standard. To validate as HTML 4.01 Transitional you need to use <META ...></META> not <META .../>
     
  3. xjohn thread starter macrumors regular

    Joined:
    Jan 6, 2003
    Location:
    Beijing
    #3
    Thanks!

    Thanks, robbieduncan!! I'll fix that.

    Any ideas about the <p> tags?
     
  4. xjohn thread starter macrumors regular

    Joined:
    Jan 6, 2003
    Location:
    Beijing
    #4
    hmmm... I fixed the meta tags like you suggested, and now they all show up as errors...

    What am I missing?
     
  5. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    Sorry - my mistake. in HTML 4.01 META tags do not have closing tags. i.e. you should have <META ...> not <META .../> or <META ...></META>
     
  6. xjohn thread starter macrumors regular

    Joined:
    Jan 6, 2003
    Location:
    Beijing
    #6
    that did it!

    That did it. Thanks again!

    Now everything's validating except for the closing </p> tags...

    Any ideas?

    (I've gone from around 200 validation errors 12 hours ago to 12 now. It's just those p tags!!:))
     
  7. xjohn thread starter macrumors regular

    Joined:
    Jan 6, 2003
    Location:
    Beijing
    #7
    Finally!

    I got it to validate by replacing the <p> tag with a <br> tag. Probably should have thought of this a while ago.

    I think the reason that it wouldn't validate before was that I'm not allowed to have a script element within a p element. Maybe?

    Anyway... it's working now. Thanks for the help!!

    John
     
  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    <P> is used to mark the start of a paragraph. <BR> is used to specify a line return. Contrary to popular belief this is not the same. You should be able to start any tag you like (more or less) within a P tag. You should not need to put a script in a paragraph unless you are using document.write to do some dynamic stuff. In general all scripts should be loaded in the HEAD element with <SCRIPT src="..."></SCRIPT> as this enables the scripts to be cached between pages.
     
  9. xjohn thread starter macrumors regular

    Joined:
    Jan 6, 2003
    Location:
    Beijing
    #9
    thanks for the clarification.

    not sure why it wasn't validating before.
     

Share This Page