473,545 Members | 2,003 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 1915
"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
1932
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" --> config.asp read values from a database, which are used to populate colours within the styles.asp sheet - for example, styles.asp looks
17
8493
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> There are many errors returned at the W3C validator but the first one has me stumped. It's my stylesheet link tag. <LINK...
31
6783
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 property which I think is probably wrong. Here's what it does: If two classes are defined in a stylesheet providing the same property, and if...
2
2042
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 statements separately in lines, e.g. --- A {css-properties:A; } A B C {css-properties:C;} A B D {css-properties:D; } A B D:hover...
7
1501
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 understand better of how cascading works. in my .css file I created this tr#noLine{ border-top-width:0; border-left-width:0;
7
2708
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 menu displays well. If I then click on the second link, the first menu from the first link still displays. How do I get make the first menu...
5
1673
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 answer is no, since these will only exist in the browser whereas the code-behind runs on the web server, but I wanted verification from you experts...
9
2016
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 also allows them to copy files from your computer to their's. It is dangerous. Avoid at all costs. CSS that isn't stored in the victim's computer....
2
1593
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> </head>
0
7410
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7668
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.