473,503 Members | 12,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cascading link styles

Hi,

I just ran into some problems when I tried to "style" the <a> elements of a
page. Basically, I have something like this:

<div id="left">
<div id="menu">
<a href="bla">Bla</a>
</div>
<a href="foo">Bar</a>
</div>

In reality even a bit more complex, but the point is, I don't quite
understand the rules by which the styles are cascaded, when I use selectors
like #menu a, #left a, a, a:link/hover/active/visited, #left
a:link/hover/active/visited etc. It seems that an a:link is more specific
than #menu a, and that the order in which the pseudo classes are specified
matters. I know that more specific rules overwrite more general ones and
that later rules overwrite earlier ones, but here I don't quite see through.
Could someone please help me?

Thanks in advance,
Thomas

Jul 20 '05 #1
4 1911
"Thomas Mlynarczyk" <bl*************@hotmail.com> schrieb:
Hi,

I just ran into some problems when I tried to "style" the <a> elements of a
page. Basically, I have something like this:

<div id="left">
<div id="menu">
<a href="bla">Bla</a>
</div>
<a href="foo">Bar</a>
</div>

In reality even a bit more complex, but the point is, I don't quite
understand the rules by which the styles are cascaded, when I use selectors
like #menu a, #left a, a, a:link/hover/active/visited, #left
a:link/hover/active/visited etc. It seems that an a:link is more specific
than #menu a, and that the order in which the pseudo classes are specified
matters. I know that more specific rules overwrite more general ones and
that later rules overwrite earlier ones, but here I don't quite see through.
Could someone please help me?

Thanks in advance,
Thomas

Hi Thomas,

You saw things clearly:
"3. those elements with a higher specifity have more weight than those
with lower specifity.

4. Sort by order all declarations applying to a given element. The
later a declaration appears in the style sheet or document, the more
weight it is given[...]" (MEYER, Eric (2004): Cascading Style Sheets.
The definitive guide. USA (O' Reilly Media) p. 69)

I uploaded an example under
http://tomasio.laudatio.com/temp/nested_links.html.
Style Definitions are inside the html-document.
--
kind regards,
tomasio
"describing an issue reveals the way to solve it"
Jul 20 '05 #2
Also sprach tomasio:
Hi Thomas,

You saw things clearly:
"3. those elements with a higher specifity have more weight than those
with lower specifity.

4. Sort by order all declarations applying to a given element. The
later a declaration appears in the style sheet or document, the more
weight it is given[...]" (MEYER, Eric (2004): Cascading Style Sheets.
The definitive guide. USA (O' Reilly Media) p. 69)

I uploaded an example under
http://tomasio.laudatio.com/temp/nested_links.html.
Style Definitions are inside the html-document.


Thank you. I will re-do my stylesheet from scratch. (I noticed that this is
quite an efficient way of sorting out problems...)
Jul 20 '05 #3
"Thomas Mlynarczyk" <bl*************@hotmail.com> schrieb:

Thank you. I will re-do my stylesheet from scratch. (I noticed that this is
quite an efficient way of sorting out problems...)

Freut mich, wenn ich helfen konnte. Ich erinnere mich, dass ich früher
auch schon mal den ganzen code neu schrieb, um klarheit zu bekommen.
--
kind regards,
tomasio
"describing an issue reveals the way to solve it"
Jul 20 '05 #4
Also sprach tomasio:
Thank you. I will re-do my stylesheet from scratch. (I noticed that
this is quite an efficient way of sorting out problems...)

Freut mich, wenn ich helfen konnte. Ich erinnere mich, dass ich früher
auch schon mal den ganzen code neu schrieb, um klarheit zu bekommen.


In diesem Fall hat es mir allerdings nicht viel gebracht. Es funktioniert
zwar alles so wie es soll, aber ich werde das Gefühl nicht los, daß sich
dasselbe Resultat auch auf wesentlich elegantere Weise erreichen lassen
könnte. Außerdem muß man sich ja noch mit den diversen Eigenheiten diverser
Browser herumärgern. So verlangt Opera < 7 offenbar unbedingt "#menu a,
#menu a:link, #menu a:visited {...}", also ein zusätzliches "#menu a" als
Selektor. Wieder ein paar überflüssige Bytes mehr...
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1928
by: Mark | last post by:
Hi - in my current pages, I have: <link href="styles.css" rel="stylesheet" type="text/css"> What I would like to do is: <!--#include file="config.asp" --> <!--#include file="styles.asp" --> ...
17
8491
by: Bruce W...1 | last post by:
I don't seem to be getting anywhere with trying to make my web page transitional XHTML. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
31
6780
by: Axel Dahmen | last post by:
I try to combine properties of several classes. This is done by assigning a space separated list of class definitions to an element. However, IE shows a kind of preference when choosing the right...
2
2039
by: pp | last post by:
What would you say about a smart script that would transform really 'cascading' style sheet into appropriate CSS structures. When coding css by hand, most often you are forced to write the...
7
1497
by: CheGueVerra | last post by:
First of all Hello all you css freak. geeks and gurus. I just started using css for some web pages I had to do at work and I'im testing some stuff at home to understand more. Now, I wanted to...
7
2705
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the...
5
1672
by: JezB | last post by:
Is it possible to programatically examine and modify a page's Styles (including Cascading Style Sheets) within the code-behind-module (eg. c#) ? My guess is that since these are HTML elements the...
9
2014
by: Radium | last post by:
Cascading Style Sheet is an extreme hazard to your privacy. It allows others on the internet to see your monitor and files. It allows them to copy images on your monitor to their computers. It...
2
1591
by: bruce131 | last post by:
Hi. I have the following XML .. <?xml-stylesheet type="text/xsl" href="try.xslt"?> <head> <title>Title</title> <desc> <p>Description<ul><li>item 1</li><li>item 2</li></ul></p> </desc>...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5604
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.