Underlining urls in paragraphs only.

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

    Underlining urls in paragraphs only.

    Hi, I'm relatively new to CSS. I'm trying to get all the urls in a group of text bracketed by
    <p></p> tags to be underlined and everywhere else to NOT be underlined. As of now my code is
    like this...

    A {color: #003366; font-size: 14px; text-decoration: none;}

    Which solves the second requirement but not the first. I don't want to have to put a style
    reference in every <a> statement enclosed by a <p> on my site. There are many, many <p>'s.

    Is this possible and how?

    Thanks in advance.

  • Nik Coughin

    #2
    Re: Underlining urls in paragraphs only.

    Stoic wrote:[color=blue]
    > Hi, I'm relatively new to CSS. I'm trying to get all the urls in a
    > group of text bracketed by <p></p> tags to be underlined and
    > everywhere else to NOT be underlined. As of now my code is like
    > this...
    >
    > A {color: #003366; font-size: 14px; text-decoration: none;}
    >
    > Which solves the second requirement but not the first. I don't want
    > to have to put a style reference in every <a> statement enclosed by a
    > <p> on my site. There are many, many <p>'s.
    >
    > Is this possible and how?
    >
    > Thanks in advance.[/color]

    a{ color: #003366; font-size: 14px; text-decoration: none; }
    p a{ text-decoration: underline; }


    Comment

    • Neal

      #3
      Re: Underlining urls in paragraphs only.

      On Mon, 13 Sep 2004 00:26:23 -0400, Stoic <nobody@nowhere .com> wrote:
      [color=blue]
      > Hi, I'm relatively new to CSS. I'm trying to get all the urls in a group
      > of text bracketed by
      > <p></p> tags to be underlined and everywhere else to NOT be underlined.
      > As of now my code is
      > like this...
      >
      > A {color: #003366; font-size: 14px; text-decoration: none;}
      >
      > Which solves the second requirement but not the first. I don't want to
      > have to put a style
      > reference in every <a> statement enclosed by a <p> on my site. There are
      > many, many <p>'s.
      >
      > Is this possible and how?
      >
      > Thanks in advance.[/color]

      a {text-decoration: none;}
      p a {text-decoration: underline;}

      But be sure any non-underlined links are obviously links. And don't use px
      to set font-size, % is the only foolproof method.

      Comment

      • Stoic

        #4
        Re: Underlining urls in paragraphs only.

        In article <opsd80wcqe6v66 56@news.individ ual.net>, neal413@yahoo.c om says...[color=blue]
        >
        > a {text-decoration: none;}
        > p a {text-decoration: underline;}
        >
        > But be sure any non-underlined links are obviously links. And don't use px
        > to set font-size, % is the only foolproof method.
        >[/color]

        Thanks everyone. After I tried to apply the code, I realized I had a bigger problem than I
        originally thought. Here's my solution...

        A { color: #003366; font-size: 100%; text-decoration: none;}
        A:link { color: #003366; text-decoration: none; }
        A:visited { color: #003366; text-decoration: none; }
        A:active { color: #999999; }
        A:hover { color: red; background-color: #FFFFFF; }
        p a { text-decoration: underline;}
        p a:link { text-decoration: underline;}
        p a:visited { text-decoration: underline;}
        p a:active { text-decoration: underline;}
        p a:hover { text-decoration: underline;}
        h1, h2, h3 { margin: 0px; padding: 0px; }
        li { list-style-position: outside; }
        li a { text-decoration: underline;}
        li a:link { text-decoration: underline;}
        li a:visited { text-decoration: underline;}
        li a:active { text-decoration: underline;}
        li a:hover { text-decoration: underline;}
        sup { font-size: 40%; font-family: sans-serif; font-weight: bold;
        text-decoration: none;}


        I also went through the entire stylesheet and changed all the px references to % for font-
        size. Thanks.

        Comment

        • Neal

          #5
          Re: Underlining urls in paragraphs only.

          On Mon, 13 Sep 2004 15:22:05 -0400, Stoic <nobody@nowhere .com> wrote:
          [color=blue]
          > A { color: #003366; font-size: 100%; text-decoration: none;}
          > A:link { color: #003366; text-decoration: none; }
          > A:visited { color: #003366; text-decoration: none; }
          > A:active { color: #999999; }
          > A:hover { color: red; background-color: #FFFFFF; }[/color]

          If you set it for A, you should not have to set it for all the pseudos as
          well. You should be able to safely remove some of the styles in the
          pseudos which are identical to what you stated in the a declaration.

          Comment

          • Stoic

            #6
            Re: Underlining urls in paragraphs only.

            In article <opseab2vz46v66 56@news.individ ual.net>, neal413@yahoo.c om says...[color=blue]
            > On Mon, 13 Sep 2004 15:22:05 -0400, Stoic <nobody@nowhere .com> wrote:
            >[color=green]
            > > A { color: #003366; font-size: 100%; text-decoration: none;}
            > > A:link { color: #003366; text-decoration: none; }
            > > A:visited { color: #003366; text-decoration: none; }
            > > A:active { color: #999999; }
            > > A:hover { color: red; background-color: #FFFFFF; }[/color]
            >
            > If you set it for A, you should not have to set it for all the pseudos as
            > well. You should be able to safely remove some of the styles in the
            > pseudos which are identical to what you stated in the a declaration.
            >[/color]

            Thanks, I think what you're saying is I can delete the A:link and A:visited because they are
            identical to the A. Gotcha.

            Comment

            • Virginia Grieco

              #7
              Re: CSS ID Class selectors

              Can anyone give me an example of what a Class ID selector would be used for?

              I am fairly new to CSS, and I understand that ID selectors can only be used
              once within a website.

              Thanks for your help.

              --




              Ginny
              Student


              Comment

              • Neal

                #8
                Re: CSS ID Class selectors

                On Tue, 14 Sep 2004 11:46:39 GMT, Virginia Grieco <vgrieco@optonl ine.net>
                wrote:
                [color=blue]
                > Can anyone give me an example of what a Class ID selector would be used
                > for?
                >
                > I am fairly new to CSS, and I understand that ID selectors can only be
                > used
                > once within a website.[/color]

                Well, that's not exactly true. An ID is used once within a webpage.
                Important difference. I can put id="foo" once on every page in my site. In
                fact, I could put it on different elements if I wanted.

                A class, though, can be used over and over again. So if it's something
                that could happen more than once on a page, use class.

                Ids can also be used as linking points where class cannot.

                Check out w3schools.com and their HTML + CSS tutorials for more detail.

                Comment

                • Harlan Messinger

                  #9
                  Re: CSS ID Class selectors


                  "Virginia Grieco" <vgrieco@optonl ine.net> wrote in message
                  news:zSA1d.1594 $4p6.1079777@ne ws4.srv.hcvlny. cv.net...[color=blue]
                  > Can anyone give me an example of what a Class ID selector would be used[/color]
                  for?[color=blue]
                  >
                  > I am fairly new to CSS, and I understand that ID selectors can only be[/color]
                  used[color=blue]
                  > once within a website.[/color]

                  In HTML, the value of an ID *attribute* must be unique within a web *page*.
                  This is independent of whether any styles are defined in CSS for a selector
                  that references a particular ID.

                  There are at least *three* reasons to specify an ID attribute for an element
                  on a web page:

                  1. As a hook for applying styles.

                  2. As a means of referencing elements in client-side code.

                  3. As a target for an internal hyperlink such as <a href="#thisplac e">.

                  Suppose you have a set of styles that should apply to paragraphs, lists,
                  hyperlinks, and so forth, only within a footnote section that appears on
                  your web pages. Give an ID to the footnote section or whatever, and then use
                  selectors based on the ID.

                  p { /* usual properties you want on your web pages */ }
                  li { /* usual properties you want on your web pages */ }
                  a { /* usual properties you want on your web pages */ }

                  #footnotes p { /* properties you want to apply within your footnotes
                  section /* }
                  #footnotes li { /* properties you want to apply within your footnotes
                  section /* }
                  #footnotes a { /* properties you want to apply within your footnotes
                  section /* }

                  ...
                  <div id="footnotes" >
                  <!-- Footnotes go here -->
                  </div>

                  Comment

                  • Jan Roland Eriksson

                    #10
                    Re: CSS ID Class selectors

                    On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
                    <h.messinger@co mcast.net> wrote:
                    [color=blue]
                    >
                    >"Virginia Grieco" <vgrieco@optonl ine.net> wrote in message
                    >news:zSA1d.159 4$4p6.1079777@n ews4.srv.hcvlny .cv.net...[color=green]
                    >> Can anyone give me an example of what a Class ID selector would be used[/color]
                    >for?[/color]
                    [...][color=blue]
                    >In HTML, the value of an ID *attribute*...[/color]

                    Well; formally speaking ID is _not_ an element attribute...

                    --
                    Rex


                    Comment

                    • Harlan Messinger

                      #11
                      Re: CSS ID Class selectors

                      Jan Roland Eriksson <jrexon@newsguy .com> wrote:
                      [color=blue]
                      >On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
                      ><h.messinger@c omcast.net> wrote:
                      >[color=green]
                      >>
                      >>"Virginia Grieco" <vgrieco@optonl ine.net> wrote in message
                      >>news:zSA1d.15 94$4p6.1079777@ news4.srv.hcvln y.cv.net...[color=darkred]
                      >>> Can anyone give me an example of what a Class ID selector would be used[/color]
                      >>for?[/color]
                      >[...][color=green]
                      >>In HTML, the value of an ID *attribute*...[/color]
                      >
                      >Well; formally speaking ID is _not_ an element attribute...[/color]

                      Why would you say that? Besides the fact that it has all the qualities
                      of an attribute, which ought to be sufficient basis for contradicting
                      you, the spec calls it an attribute, so how much more formally spoken
                      does it need to be?



                      "7.5.2 Element identifiers: the id and class attributes
                      Attribute definitions

                      id = name [CS]
                      This attribute assigns a name to an element. This name must be unique
                      in a document...."


                      --
                      Harlan Messinger
                      Remove the first dot from my e-mail address.
                      Veuillez ôter le premier point de mon adresse de courriel.

                      Comment

                      • Jan Roland Eriksson

                        #12
                        Re: CSS ID Class selectors

                        On Wed, 15 Sep 2004 09:30:54 -0400, Harlan Messinger
                        <hmessinger.rem ovethis@comcast .net> wrote:
                        [color=blue]
                        >Jan Roland Eriksson <jrexon@newsguy .com> wrote:
                        >[color=green]
                        >>On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
                        >><h.messinger@ comcast.net> wrote:[/color][/color]
                        [color=blue][color=green][color=darkred]
                        >>>In HTML, the value of an ID *attribute*...[/color][/color][/color]
                        [color=blue][color=green]
                        >>Well; formally speaking ID is _not_ an element attribute...[/color][/color]
                        [color=blue]
                        >Why would you say that?[/color]

                        Yea, that's a good question.

                        Allow me to switch on my brain before I continue to say that what I was
                        aiming at is the fact that there is a difference in what type of data
                        you can assign as a value for an ID as compared to most other
                        attributes.

                        An ID can only be assigned an ID value which in practice means that it
                        can only be a fully qualified SGML name starting with a valid name_start
                        character and optionally followed only by valid name_characters .

                        At the other side we have the vast majority of HTML element attributes
                        that takes on values that boils down to be of type CDATA. Very few HTML
                        attribute values can actually be checked for validity, if one wanted to
                        do that, since the attribute values are never parsed.

                        ID values otoh are always parsed.

                        --
                        Rex


                        Comment

                        • Harlan Messinger

                          #13
                          Re: CSS ID Class selectors

                          Jan Roland Eriksson <jrexon@newsguy .com> wrote:
                          [color=blue]
                          >On Wed, 15 Sep 2004 09:30:54 -0400, Harlan Messinger
                          ><hmessinger.re movethis@comcas t.net> wrote:
                          >[color=green]
                          >>Jan Roland Eriksson <jrexon@newsguy .com> wrote:
                          >>[color=darkred]
                          >>>On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
                          >>><h.messinger @comcast.net> wrote:[/color][/color]
                          >[color=green][color=darkred]
                          >>>>In HTML, the value of an ID *attribute*...[/color][/color]
                          >[color=green][color=darkred]
                          >>>Well; formally speaking ID is _not_ an element attribute...[/color][/color]
                          >[color=green]
                          >>Why would you say that?[/color]
                          >
                          >Yea, that's a good question.
                          >
                          >Allow me to switch on my brain before I continue to say that what I was
                          >aiming at is the fact that there is a difference in what type of data
                          >you can assign as a value for an ID as compared to most other
                          >attributes.
                          >
                          >An ID can only be assigned an ID value which in practice means that it
                          >can only be a fully qualified SGML name starting with a valid name_start
                          >character and optionally followed only by valid name_characters .
                          >
                          >At the other side we have the vast majority of HTML element attributes
                          >that takes on values that boils down to be of type CDATA. Very few HTML
                          >attribute values can actually be checked for validity, if one wanted to
                          >do that, since the attribute values are never parsed.
                          >
                          >ID values otoh are always parsed.[/color]

                          But "attribute" doesn't mean "property whose range of legal values is
                          limited" or "property whose value needs to be or can be validated
                          syntatically or semantically". Some attributes' values are restricted
                          and some aren't, that's all. So while your latest observations are
                          correct, they have no bearing on the correctness of my having referred
                          to ID as an attribute.


                          --
                          Harlan Messinger
                          Remove the first dot from my e-mail address.
                          Veuillez ôter le premier point de mon adresse de courriel.

                          Comment

                          • Jan Roland Eriksson

                            #14
                            Re: CSS ID Class selectors

                            On Wed, 15 Sep 2004 13:39:07 -0400, Harlan Messinger
                            <hmessinger.rem ovethis@comcast .net> wrote:
                            [color=blue]
                            >Jan Roland Eriksson <jrexon@newsguy .com> wrote:[/color]
                            [...][color=blue][color=green]
                            >>An ID can only be assigned an ID value...[/color][/color]
                            [...][color=blue][color=green]
                            >>At the other side ... HTML element attributes that takes on
                            >>values that boils down to be of type CDATA...[/color][/color]
                            [...][color=blue][color=green]
                            >>ID values otoh are always parsed.[/color][/color]
                            [color=blue]
                            >But "attribute" doesn't mean "property whose range of legal values is
                            >limited" or "property whose value needs to be or can be validated
                            >syntatically or semantically".[/color]

                            The SGML standard is very specific about what constitutes an
                            'attribute'; from the "Handbook" pg.127...

                            "attribute (of an element): A characteristic quality,
                            other than type or content."

                            For all times of SGML the ID (and also IDCAP, IDLINK, IDREF, IDREFCAP
                            and IDREFS) has been treated as something special, apart from "normal"
                            attributes of an element.

                            The ID family of "attributes " (ID, IDREF and IDREFS) do not really set a
                            "characteri stic quality" for the element where they appear but instead
                            they serve to provide identifiable points of reference and "hooks" to
                            points of reference in a document.
                            [color=blue]
                            >some attributes' values are restricted and some aren't, that's all.[/color]

                            The possible values for 'ID' in HTML is definitely described by a
                            (ridiculously big, but finite) number. That is not so with CDATA
                            attributes though, their range of allowed values are infinite.
                            [color=blue]
                            >So while your latest observations are correct, they have no bearing
                            >on the correctness of my having referred to ID as an attribute.[/color]

                            If you only want my approval on your use of words I can grant you that
                            straight off. The "Handbook" lists ID, IDREF and IDREFS as attributes
                            too, but continues to great length to describe what it is that makes the
                            ID... family of "attributes " so special.

                            I'm an old "SGML sod" and I have over the years created quite a number
                            of "HTML authoring tools" based on the SP suite. Most often I find that
                            SGMLNORM is my best friend when it comes to production of markup good
                            enough to put up on a server somewhere.

                            ID's comes in handy in local processing at times but I have yet to find
                            that I define a set of ID values for any other purpose than to provide
                            hooks for linking and cross refs.

                            Others do use more "modern" approaches as in what came in on
                            comp.text.sgml just today...

                            <http://nedron.net/xml-test/fedora-boot-floppy.xml>

                            ....where we can find some solid use of ID's in a 'docbook' document to
                            create parts of visible content that is gathered from ID'ed elements in
                            the original markup.

                            (XSLT capable version of Mozilla is required to view that document)

                            I'm not at all convinced that the 'TOC' produced on the fly (not part of
                            the visible markup) in that document could be said to be a
                            "characteri stic quality" of the elements that was IDentified to be used
                            as a source of that 'TOC'? Correct me if I'm wrong?

                            --
                            Rex


                            Comment

                            • Harlan Messinger

                              #15
                              Re: CSS ID Class selectors

                              Jan Roland Eriksson <jrexon@newsguy .com> wrote:
                              [color=blue]
                              >On Wed, 15 Sep 2004 13:39:07 -0400, Harlan Messinger
                              ><hmessinger.re movethis@comcas t.net> wrote:
                              >[color=green]
                              >>Jan Roland Eriksson <jrexon@newsguy .com> wrote:[/color]
                              >[...][color=green][color=darkred]
                              >>>An ID can only be assigned an ID value...[/color][/color]
                              >[...][color=green][color=darkred]
                              >>>At the other side ... HTML element attributes that takes on
                              >>>values that boils down to be of type CDATA...[/color][/color]
                              >[...][color=green][color=darkred]
                              >>>ID values otoh are always parsed.[/color][/color]
                              >[color=green]
                              >>But "attribute" doesn't mean "property whose range of legal values is
                              >>limited" or "property whose value needs to be or can be validated
                              >>syntaticall y or semantically".[/color]
                              >
                              >The SGML standard is very specific about what constitutes an
                              >'attribute'; from the "Handbook" pg.127...
                              >
                              > "attribute (of an element): A characteristic quality,
                              > other than type or content."
                              >
                              >For all times of SGML the ID (and also IDCAP, IDLINK, IDREF, IDREFCAP
                              >and IDREFS) has been treated as something special, apart from "normal"
                              >attributes of an element.
                              >
                              >The ID family of "attributes " (ID, IDREF and IDREFS) do not really set a
                              >"characteristi c quality" for the element where they appear but instead
                              >they serve to provide identifiable points of reference and "hooks" to
                              >points of reference in a document.
                              >[color=green]
                              >>some attributes' values are restricted and some aren't, that's all.[/color]
                              >
                              >The possible values for 'ID' in HTML is definitely described by a
                              >(ridiculousl y big, but finite) number. That is not so with CDATA
                              >attributes though, their range of allowed values are infinite.
                              >[color=green]
                              >>So while your latest observations are correct, they have no bearing
                              >>on the correctness of my having referred to ID as an attribute.[/color]
                              >
                              >If you only want my approval on your use of words I can grant you that
                              >straight off. The "Handbook" lists ID, IDREF and IDREFS as attributes
                              >too, but continues to great length to describe what it is that makes the
                              >ID... family of "attributes " so special.[/color]

                              What do I want with your approval? I knew I was right and the checking
                              the official sources confirmed it. The only question in my mind was
                              why you were continuing to reason why ID shouldn't be called an
                              attribute. The "specialnes s" of ID is irrelevant--the definition of
                              "attribute" isn't contingent on the attribute being non-special--and
                              the lack of restrictions on its value isn't relevant at all. (By the
                              way--since when is the ID of an HTML element--we were talking about
                              HTML, not SGML--not restricted?)

                              [snipping a bunch of stuff whose relevance eludes me]

                              --
                              Harlan Messinger
                              Remove the first dot from my e-mail address.
                              Veuillez ôter le premier point de mon adresse de courriel.

                              Comment

                              Working...