Forums

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

Home Forums CSS Divs

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34325

    Hi
    I am coming here with a newbie-question.

    Sometimes I see in Css-codes that peolpe put div before their names. like

    div#header { filling:out}

    Why is that div there, isn’t it enough to have it in the html file?

    #87037
    Johann
    Member

    uhm sorry, the forums were totally crapping out just now.. what I said was: as you said, that’s unneed. any ID should only ever occur once per page, so the tag name doen’t add any information.

    #87039

    Ok thanks. The thing is that I have seen it on many of Chris Coyier’s screencasts. Seems weird that such a well educated css artist write inappropriate code

    #87044
    WouterJ
    Member

    With IDs it make no sence, but with classes it can be very helpfull. For instance:

    You have a class named highlight. If it is an h1 element you want a yellow background, but a highlighted span tag should have only a yellow text color. In CSS you do this:

    h1.highlight     {  background: yellow; }
    span.highlight { color: yellow; }

    But with IDs it is better to use only #idName, because this is faster.

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