CSS question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nickyeng
    Contributor
    • Nov 2006
    • 252

    CSS question

    Code:
    h1.b { font-weight: bold }
    This one explain as, define a class b to h1 element. To use this style, use the following code in html :
    -----------------
    <h1 class="b">This is header title</h1>

    how about the following ? :
    Code:
    . { text-decoration: underline }
    how to explain that? which html element can use it?
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Originally posted by nickyeng

    how about the following ? :
    Code:
    . { text-decoration: underline }
    I wasn't aware you could use that. I thought you had to say for example:
    Code:
    .u { text-decoration: underline }
    and use it in :
    Code:
    <p class="u">here is an underline paragraph</p>
    <p>here is an underlined <span class="u">word</span> in a paragraph</p>
    <h1 class="u">here is an underlined header</u>

    Comment

    • nickyeng
      Contributor
      • Nov 2006
      • 252

      #3
      hi there,

      i know how your example works.

      all i been thru for my website design, the following are used by me.
      Code:
      .u { text-decoration: underline }
      h1.u { font-weight: bold }
      h1#x { font-weight: normal }
      #x { text-decoration: underline }
      others i never use before.

      As the question i ask about
      Code:
       . { text-decoration: underline }
      this happens in my exam question. And i dont know how to answer that, i just say, any html element can use it in a document.

      haha.
      thanks for the help.

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        The universal selector is an asterisk '*'. If you just use a period, the validator issues a parsing error. While what you are doing may appear to work, it might just be the browser guessing at what you are trying to do and you can't count on it to be consistent across browsers or pages.

        Comment

        • jhardman
          Recognized Expert Specialist
          • Jan 2007
          • 3405

          #5
          you said this was an exam question?

          I think it was a trick question. As drhoward said, some browsers might recognize it, but it doesn't follow any standard I know.

          Jared

          Comment

          • nickyeng
            Contributor
            • Nov 2006
            • 252

            #6
            Originally posted by jhardman
            you said this was an exam question?

            I think it was a trick question. As drhoward said, some browsers might recognize it, but it doesn't follow any standard I know.

            Jared
            yeah it appeared in my test asking me to explain it.

            it costs me 8mark, but it shouldn't be a matter to me.

            thanks for the helps.

            Comment

            Working...