Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS So I ran some of my code through W3C’s validator……..

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #43261
    Krish1980
    Participant

    And I found that

    a) I cannot use a div inside an ‘a’ tag?! If that’s the case, I’d be restricted by a great deal. It tells me that I cannot use a block level element inside an ‘a’ tag(never mind that in many cases, whenever I wish to show a background for the link, I use display ‘block’.)

    b) Normally, whenever I create a menu, I give a background to the ul, give it an auto height, and then use `
    ` before the ul ends(when the li’s are floated). Apparently, even that’s not allowed. ( I usually do this to avoid using a container div for the ul befotre which I’d use the clearboth class)

    Are these fatal errors? Because they seem to display quite well on modern browsers.

    #127570
    CrocoDillon
    Participant

    In html5 (a) is allowed. Can’t see what (b) is about.

    #127588
    wolfcry911
    Participant

    CrocoDillon is correct, a block level is allowed inside an anchor in html5, but I have a feeling you don’t even need it. You can make an element (like an anchor) display block and apply a background to it without failing validation. In other doctypes you probably want to use a span instead of a div.

    Didn’t fully understand b), but I’m guessing you used some element inside the ul to clear the floating li – you can’t. li is the only child allowed in ul and ol. Why not use overflow: hidden or .clearfix on the ul (or simply give it a height) instead?

    #127589
    Kitty Giraudel
    Participant

    > In html5 (a) is allowed. Can’t see what (b) is about.

    Same here.

    #127590
    Merri
    Participant

    Clearfixes you can or can’t use with a menu:

    /* can’t use this – you won’t see the child dropdowns as they go outside UL! */
    ul {
    overflow: hidden;
    }

    /* pseudo clearfix element */
    ul {
    width: 100%; /* give any width (to trigger hasLayout in older IEs, gives the same end result) */
    }
    ul:after {
    clear: both;
    content: ”;
    display: block;
    }

    I find it a bit odd people keep on writing their CSS-minded elements and attributes in HTML. I mean things like this:


    Personally I rather just keep it all in CSS and not add extra stuff to HTML just because I need a clearfix.

    #127601
    TheDoc
    Member

    I think everyone has hit the nail on the head here. I also think you should get that clearing line break out of there. It has no business being in your HTML!

    #127633
    __
    Participant

    (b) is throwing an error because a `
    ` is not allowed as a direct child of a list. Lists can only hold `

  • ` elements (or `
    `/`

    ` elements, in the case of a definition list).
#127639
Merri
Participant

The meaning of…

… is “the latest and greatest HTML”. You will get standards mode even in IE6 with that particular doctype so it isn’t really different from HTML 4.01 Strict or XHTML 1.0 Strict in that regard. You are not forced to write HTML5 tags if you use the doctype above so you can limit yourself to old tags and things will be fine. If you want HTML5 elements for improved semantics then you can use something like html5shiv.js or Modernizr to add HTML5 tags to older IEs. That of course means JavaScript. If your site targets mostly home users and non-corporate business users than it is quite likely you don’t need to worry about older IEs so much and scripts (and notifications to upgrade browser) will be ok. It is stagnant slowly moving corporates that are the most troublesome when it comes to browsers.

#127647
__
Participant

> The meaning of… `` … is “the latest and greatest HTML”.

kinda. To the validator, it means to use HTML5 rules for validation.

To browsers, it means nothing more or less than any other doctype. That’s why it was chosen: all major browsers read as far as `` “working” inside of an `` won’t be a problem despite being “not allowed” in earlier versions of HTML – it *works* just fine in almost all cases (IE8+, AFAIK). That’s *why* HTML5 allows it.

#127714
Kitty Giraudel
Participant

> Now, this may seem like a stupid question, but if I use the doctype for html 5 and start using html5 , will the pages be displayed properly on older browsers?(like say, IE8)

Yes.

However if you ever use HTML5 elements like header, article and such, you might want to use [html5shiv](http://code.google.com/p/html5shiv/).

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘CSS’ is closed to new topics and replies.