469,631 Members | 1,776 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

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.

Jul 20 '05 #1
16 1851
Stoic wrote:
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.


a{ color: #003366; font-size: 14px; text-decoration: none; }
p a{ text-decoration: underline; }
Jul 20 '05 #2
On Mon, 13 Sep 2004 00:26:23 -0400, Stoic <no****@nowhere.com> wrote:
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.


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.
Jul 20 '05 #3
In article <op**************@news.individual.net>, ne*****@yahoo.com says...

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.


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.
Jul 20 '05 #4
On Mon, 13 Sep 2004 15:22:05 -0400, Stoic <no****@nowhere.com> wrote:
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; }


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.
Jul 20 '05 #5
In article <op**************@news.individual.net>, ne*****@yahoo.com says...
On Mon, 13 Sep 2004 15:22:05 -0400, Stoic <no****@nowhere.com> wrote:
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; }


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.


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.
Jul 20 '05 #6
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
Jul 20 '05 #7
On Tue, 14 Sep 2004 11:46:39 GMT, Virginia Grieco <vg*****@optonline.net>
wrote:
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.


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.
Jul 20 '05 #8

"Virginia Grieco" <vg*****@optonline.net> wrote in message
news:zS********************@news4.srv.hcvlny.cv.ne t...
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.


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="#thisplace">.

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>

Jul 20 '05 #9
On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
<h.*********@comcast.net> wrote:

"Virginia Grieco" <vg*****@optonline.net> wrote in message
news:zS********************@news4.srv.hcvlny.cv.n et...
Can anyone give me an example of what a Class ID selector would be usedfor?

[...]In HTML, the value of an ID *attribute*...


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

--
Rex
Jul 20 '05 #10
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
<h.*********@comcast.net> wrote:

"Virginia Grieco" <vg*****@optonline.net> wrote in message
news:zS********************@news4.srv.hcvlny.cv. net...
Can anyone give me an example of what a Class ID selector would be used

for?

[...]
In HTML, the value of an ID *attribute*...


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


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?

http://www.w3.org/TR/html4/struct/global.html#h-7.5.2

"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.
Jul 20 '05 #11
On Wed, 15 Sep 2004 09:30:54 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
<h.*********@comcast.net> wrote:
In HTML, the value of an ID *attribute*...
Well; formally speaking ID is _not_ an element attribute...
Why would you say that?


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
Jul 20 '05 #12
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Wed, 15 Sep 2004 09:30:54 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Tue, 14 Sep 2004 11:43:46 -0400, "Harlan Messinger"
<h.*********@comcast.net> wrote:In HTML, the value of an ID *attribute*...Well; formally speaking ID is _not_ an element attribute...

Why would you say that?


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.


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.
Jul 20 '05 #13
On Wed, 15 Sep 2004 13:39:07 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:
Jan Roland Eriksson <jr****@newsguy.com> wrote: [...]
An ID can only be assigned an ID value... [...]At the other side ... HTML element attributes that takes on
values that boils down to be of type CDATA... [...]ID values otoh are always parsed.

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".
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
"characteristic 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.
some attributes' values are restricted and some aren't, that's all.
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.
So while your latest observations are correct, they have no bearing
on the correctness of my having referred to ID as an attribute.


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
"characteristic quality" of the elements that was IDentified to be used
as a source of that 'TOC'? Correct me if I'm wrong?

--
Rex
Jul 20 '05 #14
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Wed, 15 Sep 2004 13:39:07 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:
Jan Roland Eriksson <jr****@newsguy.com> wrote:

[...]
An ID can only be assigned an ID value...[...]At the other side ... HTML element attributes that takes on
values that boils down to be of type CDATA...[...]ID values otoh are always parsed.

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".


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
"characteristic 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.
some attributes' values are restricted and some aren't, that's all.


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.
So while your latest observations are correct, they have no bearing
on the correctness of my having referred to ID as an attribute.


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.


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 "specialness" 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.
Jul 20 '05 #15
On Thu, 16 Sep 2004 01:11:38 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Wed, 15 Sep 2004 13:39:07 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:
Jan Roland Eriksson <jr****@newsguy.com> wrote:[...]
An ID can only be assigned an ID value...


[...]
...why you were continuing to reason why ID shouldn't be called an
attribute.
As per ISO8879[1] (the SGML standard) ID is listed among the other
attribute definitions because it's convenient to do so, still the
characteristics of ID (plus IDREF and IDREFS) is so different from other
attribute types that it must receive special treatment.
The "specialness" of ID is irrelevant...
Nope.
...and the lack of restrictions on its value isn't relevant at all.
You got that backwards, ID does have restrictions on its value
assignments. Most other attributes as defined in HTML have not[2].
(By the way--since when is the ID of an HTML element--we were
talking about HTML, not SGML--not restricted?)


What?

HTML claims to be an application of SGML[3][4], as such HTML is required
to follow all parts of the SGML standard. It is not allowed for HTML to
change the foundation upon which it is built.

[1]<http://www.iso.org/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=16387 >
[2]<http://www.htmlhelp.com/reference/html40/attrs.html>
[3]<http://www.w3.org/TR/html4/conform.html#h-4.1>
[4]<http://www.w3.org/TR/html4/sgml/intro.html>

--
Rex
Jul 20 '05 #16
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Thu, 16 Sep 2004 01:11:38 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:
Jan Roland Eriksson <jr****@newsguy.com> wrote:
On Wed, 15 Sep 2004 13:39:07 -0400, Harlan Messinger
<hm*******************@comcast.net> wrote:

Jan Roland Eriksson <jr****@newsguy.com> wrote:
[...]
>An ID can only be assigned an ID value...

[...]
...why you were continuing to reason why ID shouldn't be called an
attribute.


As per ISO8879[1] (the SGML standard) ID is listed among the other
attribute definitions because it's convenient to do so, still the
characteristics of ID (plus IDREF and IDREFS) is so different from other
attribute types that it must receive special treatment.


When a set X is defined as all {x(i)} that have certain
characteristics, there is no implicit proviso "except for those x(i)
that have something else special about them". ID meets the definition
of "attribute", and is on top of it explicitly declared to be one.
There is no precept that justifies, "Oh, but it has other special
properties, so it really isn't an attribute after all."
The "specialness" of ID is irrelevant...
Nope.


The standards say you're wrong.
...and the lack of restrictions on its value isn't relevant at all.


You got that backwards, ID does have restrictions on its value
assignments. Most other attributes as defined in HTML have not[2].


Correct, I got my wires reversed.
--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Mason A. Clark | last post: by
1 post views Thread by Pete Griffint | last post: by
7 posts views Thread by Jukka K. Korpela | last post: by
3 posts views Thread by WebCM | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.