Class an ID syntax

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    Class an ID syntax

    Ok

    i know now that i use a class if elements repeat. And i can use an ID if
    they are unique.

    I now have a problem.

    With ID all is well, but does not validate. So i have to rewrite the
    code... but how? I am confused with all the "." and "#". What is the
    correct syntax (if any?)

    Mark

    <part code>
    #info {
    width:320px;
    padding:0;
    margin:0;
    float:right;
    }

    #info .omschrijving {
    margin:0;
    padding:0px 30px 20px 10px;
    width:270px;
    font-size:75%;
    }

    #info h2 {
    margin:0;
    padding:0 0 10px 0px;
    width:320px;
    }
    </part code>
    ------------------------------------------
    <part code html>
    <div id="info">
    <h2>Item 1</h2>
    <p class="omschrij ving">bla bla</p>
    </div>
    <div id="info">
    <h2>Item 2</h2>
    <p class="omschrij ving">bla bla</p>
    </div>
    </part code html>

    -------------------------------------------
    -------------------------------------------
    This does not work:

    <part new code html>
    <div class="info">
    <h2>Item 1</h2>
    <p class="omschrij ving">bla bla</p>
    </div>
    <div class="info">
    <h2>Item 2</h2>
    <p class="omschrij ving">bla bla</p>
    </div>
    </part new code html>

    ------------------------------------------
    <new css>

    ..info {
    }

    ..info .omschrijving {

    }

    ..info h2 {

    }

    </new css>

  • Benjamin Niemann

    #2
    Re: Class an ID syntax

    Mark wrote:
    [color=blue]
    > Ok
    >
    > i know now that i use a class if elements repeat. And i can use an ID if
    > they are unique.
    >
    > I now have a problem.
    >
    > With ID all is well, but does not validate. So i have to rewrite the
    > code... but how? I am confused with all the "." and "#". What is the
    > correct syntax (if any?)
    >
    > [snip]
    >
    > -------------------------------------------
    > This does not work:
    >
    > <part new code html>
    > <div class="info">
    > <h2>Item 1</h2>
    > <p class="omschrij ving">bla bla</p>
    > </div>
    > <div class="info">
    > <h2>Item 2</h2>
    > <p class="omschrij ving">bla bla</p>
    > </div>
    > </part new code html>
    >
    > ------------------------------------------
    > <new css>
    >
    > .info {
    > }
    >
    > .info .omschrijving {
    >
    > }
    >
    > .info h2 {
    >
    > }
    >
    > </new css>[/color]

    Looks correct to me. Can you give the URL to a complete document, perhaps
    the problem is burries somewhere else.

    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://www.odahoda.de/

    Comment

    • Mark

      #3
      Re: Class an ID syntax

      Benjamin Niemann wrote:[color=blue]
      > Mark wrote:
      >
      >[color=green]
      >>Ok
      >>
      >>i know now that i use a class if elements repeat. And i can use an ID if
      >>they are unique.
      >>
      >>I now have a problem.
      >>
      >>With ID all is well, but does not validate. So i have to rewrite the
      >>code... but how? I am confused with all the "." and "#". What is the
      >>correct syntax (if any?)
      >>
      >>[snip]
      >>
      >>-------------------------------------------
      >>This does not work:
      >>
      >><part new code html>
      >><div class="info">
      >><h2>Item 1</h2>
      >><p class="omschrij ving">bla bla</p>
      >></div>
      >><div class="info">
      >><h2>Item 2</h2>
      >><p class="omschrij ving">bla bla</p>
      >></div>
      >></part new code html>
      >>
      >>------------------------------------------
      >><new css>
      >>
      >>.info {
      >>}
      >>
      >>.info .omschrijving {
      >>
      >>}
      >>
      >>.info h2 {
      >>
      >>}
      >>
      >></new css>[/color]
      >
      >
      > Looks correct to me. Can you give the URL to a complete document, perhaps
      > the problem is burries somewhere else.
      >[/color]

      Ok, i think there is something else wrong, so here is the URL:

      The red background is not going to stay, but a little help. The text
      has to be in this arrea.

      For the green arrea: here has to be the title (<h2>)



      I hope you can help me out!
      Thanks
      Mark

      Comment

      • Mark

        #4
        Re: Class an ID syntax

        <snip>

        I did solve it :0)

        Because the classes where in a div (#dvd), i had to extend my definitions.

        So, instead of

        ..winkelwagen

        #dvd .winkelwagen

        etc.

        Mark

        Comment

        • Els

          #5
          Re: Class an ID syntax

          Mark wrote:
          [color=blue]
          > <snip>
          >
          > I did solve it :0)
          >
          > Because the classes where in a div (#dvd), i had to extend my definitions.
          >
          > So, instead of
          >
          > .winkelwagen
          >
          > #dvd .winkelwagen
          >
          > etc.[/color]

          Being that specific is only needed if the style needs to override a
          previous style that is more specific than just .winkelwagen.

          --
          Els http://locusmeus.com/
          Sonhos vem. Sonhos vão. O resto é imperfeito.
          - Renato Russo -
          Now playing: Steppenwolf - The Ostrich

          Comment

          • Benjamin Niemann

            #6
            Re: Class an ID syntax

            Mark wrote:
            [color=blue]
            > http://www.keyone.nl/lab/beeldlijn/nl/collection.asp[/color]

            An unrelated issue: you declared the encoding as 'iso-8859-1', but you are
            actually using 'windows-1252'. Some browsers may render e.g. the euro sign
            as you intended, others will render it correctly (not at all, or with a
            placeholder for non-printable characters, usually a boxshape).

            --
            Benjamin Niemann
            Email: pink at odahoda dot de
            WWW: http://www.odahoda.de/

            Comment

            • Mark

              #7
              Re: Class an ID syntax

              Els wrote:[color=blue]
              > Mark wrote:
              >
              >[color=green]
              >><snip>
              >>
              >>I did solve it :0)
              >>
              >>Because the classes where in a div (#dvd), i had to extend my definitions.
              >>
              >>So, instead of
              >>
              >>.winkelwage n
              >>
              >>#dvd .winkelwagen
              >>
              >>etc.[/color]
              >
              >
              > Being that specific is only needed if the style needs to override a
              > previous style that is more specific than just .winkelwagen.
              >[/color]

              I am not sure what you mean by this. Can you explain it a bit more?

              thanks,
              mark

              Comment

              • Mark

                #8
                Re: Class an ID syntax

                Benjamin Niemann wrote:[color=blue]
                > Mark wrote:
                >
                >[color=green]
                >>http://www.keyone.nl/lab/beeldlijn/nl/collection.asp[/color]
                >
                >
                > An unrelated issue: you declared the encoding as 'iso-8859-1', but you are
                > actually using 'windows-1252'. Some browsers may render e.g. the euro sign
                > as you intended, others will render it correctly (not at all, or with a
                > placeholder for non-printable characters, usually a boxshape).
                >[/color]

                Thanks.
                Is it okay just to change it into windows-1252 or do i need to know more
                about it?

                Mark

                Comment

                • Els

                  #9
                  Re: Class an ID syntax

                  Mark wrote:
                  [color=blue]
                  > Els wrote:[color=green]
                  >> Mark wrote:
                  >>[color=darkred]
                  >>>I did solve it :0)
                  >>>Because the classes where in a div (#dvd), i had to extend my definitions.
                  >>>So, instead of
                  >>>.winkelwag en
                  >>>#dvd .winkelwagen
                  >>>etc.[/color]
                  >>
                  >> Being that specific is only needed if the style needs to override a
                  >> previous style that is more specific than just .winkelwagen.[/color]
                  >
                  > I am not sure what you mean by this. Can you explain it a bit more?[/color]

                  There normally is no need to add #dvd just because .winkelwagen is
                  inside #dvd.

                  Example (off the top of my head, not tested, just an example):

                  <div id="content">
                  <p class="text">bl a bla bla bla</p>
                  <p class="more">mo re more more more</p>
                  </div>

                  If you have set a style in your css like:
                  #content p{background:re d;}

                  then just:
                  .text{backgroun d:blue;}
                  won't work.

                  "#content p" is more specific than ".text", and the blue background
                  will be ignored in favour of the red background that was set.

                  In that case, to 'supercede' the set red background, you'll need:
                  #content p.text{backgrou nd:blue;}
                  to make it work.

                  HTH

                  --
                  Els http://locusmeus.com/
                  Sonhos vem. Sonhos vão. O resto é imperfeito.
                  - Renato Russo -
                  Now playing: The Eagles - Hotel California

                  Comment

                  • Benjamin Niemann

                    #10
                    Re: Class an ID syntax

                    Mark wrote:
                    [color=blue]
                    > Benjamin Niemann wrote:[color=green]
                    >> Mark wrote:
                    >>
                    >>[color=darkred]
                    >>>http://www.keyone.nl/lab/beeldlijn/nl/collection.asp[/color]
                    >>
                    >>
                    >> An unrelated issue: you declared the encoding as 'iso-8859-1', but you
                    >> are actually using 'windows-1252'. Some browsers may render e.g. the euro
                    >> sign as you intended, others will render it correctly (not at all, or
                    >> with a placeholder for non-printable characters, usually a boxshape).
                    >>[/color]
                    >
                    > Thanks.
                    > Is it okay just to change it into windows-1252 or do i need to know more
                    > about it?[/color]

                    Declaring the charset as windows-1252 would be the the easiest fix and
                    should probably work on all major browsers. But people may argue that
                    windows-1252 is 'bad', because it is a proprietary, vendor specific
                    character set - in contrast to iso-* or unicode.
                    If you prefer a vendor neutral character set, stay with iso-8859-1 and use
                    character references for characters not in iso-8859-1 (e.g. &#x201a; for
                    the euro sign). validator.w3.or g will tell you which characters are illegal
                    in iso-8859-1 and you can use
                    <http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT>
                    to map these to the correct unicode codepoints.

                    --
                    Benjamin Niemann
                    Email: pink at odahoda dot de
                    WWW: http://www.odahoda.de/

                    Comment

                    • Alan J. Flavell

                      #11
                      Re: Class an ID syntax

                      On Fri, 19 Aug 2005, Mark wrote:
                      [color=blue]
                      > Is it okay just to change it into windows-1252[/color]

                      Windows-1252 is a Microsoft proprietary encoding - in practice, most
                      web clients will support this encoding, but some recipients would
                      consider it rude of you to transmit www pages in a proprietary
                      encoding - even if their software supports it.

                      Based on what you currently seem to be doing, I'd recommend sending
                      iso-8859-1, and representing any characters which are not in that
                      encoding using &-notation, e.g &euro;

                      If you're extruding this HTML from some proprietary MS software, as it
                      appears may be the case, then you'd need to find out more about how to
                      get that software under control! I, like many another here, can
                      advise you on what would be correct CSS, HTML etc., but this isn't
                      really the place to learn how to use proprietary applications which
                      are extruding faulty web formats...

                      You can, normally, identify which characters these are by submitting
                      your HTML to the W3C's validator (validator.w3.o rg): it will throw a
                      warning on any characters that it dislikes, including Windows-1252
                      characters when your document was advertised as iso-8859-1.


                      You have a handful of such errors reported, not only the coded
                      character 128 decimal (euro) but also 146, 147, 148, and 149. Looks
                      like Windows-1252 "smart" single and double quotes (one learns that
                      whenever MS say "smart", it's going to be dumb).

                      If you want to explore other options, I offer quite a lot of
                      discussion (probably a lot more than you want/need, but take as
                      much as you care to) about various possibilities here:


                      hope this helps.


                      Comment

                      • Andreas Prilop

                        #12
                        Re: Class an ID syntax

                        On Fri, 19 Aug 2005, Benjamin Niemann wrote:
                        [color=blue]
                        > If you prefer a vendor neutral character set, stay with iso-8859-1 and use
                        > character references for characters not in iso-8859-1 (e.g. &#x201a; for
                        > the euro sign).[/color]

                        Decimal character references like ‚ (single quote low-9) and
                        € (euro) are better supported. In the special case "euro sign",
                        it is still better to use the entity &euro; .

                        --
                        I used to believe in reincarnation in a former life.

                        Comment

                        • Mark

                          #13
                          Re: Class an ID syntax

                          Alan J. Flavell wrote:[color=blue]
                          > On Fri, 19 Aug 2005, Mark wrote:
                          >
                          >[color=green]
                          >>Is it okay just to change it into windows-1252[/color]
                          >
                          >
                          > Windows-1252 is a Microsoft proprietary encoding - in practice, most
                          > web clients will support this encoding, but some recipients would
                          > consider it rude of you to transmit www pages in a proprietary
                          > encoding - even if their software supports it.
                          >
                          > Based on what you currently seem to be doing, I'd recommend sending
                          > iso-8859-1, and representing any characters which are not in that
                          > encoding using &-notation, e.g &euro;
                          >
                          > If you're extruding this HTML from some proprietary MS software, as it
                          > appears may be the case, then you'd need to find out more about how to
                          > get that software under control! I, like many another here, can
                          > advise you on what would be correct CSS, HTML etc., but this isn't
                          > really the place to learn how to use proprietary applications which
                          > are extruding faulty web formats...
                          >
                          > You can, normally, identify which characters these are by submitting
                          > your HTML to the W3C's validator (validator.w3.o rg): it will throw a
                          > warning on any characters that it dislikes, including Windows-1252
                          > characters when your document was advertised as iso-8859-1.
                          > http://validator.w3.org/check?verbos...collection.asp
                          >
                          > You have a handful of such errors reported, not only the coded
                          > character 128 decimal (euro) but also 146, 147, 148, and 149. Looks
                          > like Windows-1252 "smart" single and double quotes (one learns that
                          > whenever MS say "smart", it's going to be dumb).
                          >
                          > If you want to explore other options, I offer quite a lot of
                          > discussion (probably a lot more than you want/need, but take as
                          > much as you care to) about various possibilities here:
                          > http://ppewww.ph.gla.ac.uk/~flavell/charset/checklist
                          >
                          > hope this helps.
                          >
                          >[/color]

                          Thanks, this helps!

                          There was some ' and " and bullets from some MS software indeed.

                          Good to know.

                          grtz

                          Comment

                          • Harlan Messinger

                            #14
                            Re: Class an ID syntax

                            Mark wrote:[color=blue]
                            > Els wrote:
                            >[color=green]
                            >> Mark wrote:
                            >>
                            >>[color=darkred]
                            >>> <snip>
                            >>>
                            >>> I did solve it :0)
                            >>>
                            >>> Because the classes where in a div (#dvd), i had to extend my
                            >>> definitions.
                            >>>
                            >>> So, instead of
                            >>>
                            >>> .winkelwagen
                            >>>
                            >>> #dvd .winkelwagen
                            >>>
                            >>> etc.[/color]
                            >>
                            >> Being that specific is only needed if the style needs to override a
                            >> previous style that is more specific than just .winkelwagen.
                            >>[/color]
                            >
                            > I am not sure what you mean by this. Can you explain it a bit more?
                            >[/color]

                            Suppose you have the following HTML code:

                            <div id="foo">
                            <p class="bar" id="myself">Som ething</p>
                            </div>

                            Any of the following selectors could affect the appearance of the paragraph:

                            p
                            div p
                            p.bar
                            #myself
                            p#myself
                            div .bar
                            #foo .bar
                            #foo p
                            #foo p.bar
                            div#foo p

                            and so on. Suppose you have several of these in your stylesheets all of
                            which specify a value for the same CSS property. For example:

                            p { color: blue; }
                            #foo p { color: red; }
                            #myself { color: green; }
                            #foo .bar { color: black; }

                            How this conflict will be resolved--whether the paragraph will be
                            displayed in blue, red, green, black, or some other color--depends on
                            applying the cascade rules to the styles you've defined. A "priority" is
                            computed for each selector that specifies a particular property, and the
                            selector with the highest priority "wins". See





                            Comment

                            • Shawn K. Quinn

                              #15
                              Re: Class an ID syntax

                              begin quotation
                              from Mark <scheper@xs4all .nl>
                              in message <4305CE03.40309 00@xs4all.nl>[color=blue]
                              > Benjamin Niemann wrote:[color=green]
                              >> An unrelated issue: you declared the encoding as 'iso-8859-1', but you are
                              >> actually using 'windows-1252'.[/color]
                              >
                              > Thanks.
                              > Is it okay just to change it into windows-1252 or do i need to know more
                              > about it?[/color]

                              I cannot in good faith recommend any use of encodings proprietary to
                              Microsoft products in a World Wide Web context. It would be best to
                              re-encode as iso-8859-1.

                              --
                              ___ _ _____ |*|
                              / __| |/ / _ \ |*| Shawn K. Quinn
                              \__ \ ' < (_) | |*| skquinn@speakea sy.net
                              |___/_|\_\__\_\ |*| Houston, TX, USA

                              Comment

                              Working...