473,493 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Same selector different outcome

I have two test vertical menus. If I apply a border-bottom using a
selecter of

div.vbar a

It looks fine.

If I apply the border-bottom using a selecter of

div.vbar ul li a

it applies the border but it extends farther out.
My understanding is that I am applying the border to the same
element,
I don't understand why it should look different. If anyone can shed
some
light on this, it would be appreciatted.

Jorge

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<style type="text/css">
h1
{
text-align:center;
}

div.vbar2, div.vbar1
{
float:left;
border: 1px solid #C0C0C0;
background-color: white;
border-bottom-width: 0;
width: 170px;
}

div.vbar2
{
clear:left;
}

div.vbar1
{
clear:right;
}

* html .vbar2{
width: 164px;
}

* html .vbar1{
width: 164px;
}

div.vbar2 ul, div.vbar1 ul{
padding: 0;
margin: 0;
list-style-type: none;
}

div.vbar1 ul li a
{
padding: 4px 3px;
display: block;
width: 100%; /*Define width for IE6's sake*/
color: #595959;
text-decoration: none;
border-bottom: 1px solid blue;
}

div.vbar2 a{
padding: 4px 3px;
display: block;
width: 100%; /*Define width for IE6's sake*/
color: #595959;
text-decoration: none;
border-bottom: 1px solid green;
}
html>body .vbar2 a{ /*Non IE rule*/
width: auto;
}
html>body .vbar1 a{ /*Non IE rule*/
width: auto;
}
div.vbar2 a:hover,div.vbar1 a:hover
{
background-color: #F8FBBD;
color: black;
}

</style>
</head>
<body>
<div id="header">
<h1>Heading</h1>
</div>
<div class="vbar1">
<ul>
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
</ul>
</div>
<div class="vbar2">
<ul>
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
</ul>
</div>

</body>
</html>

Feb 21 '07 #1
1 1713
On 21 Feb, 17:02, "jorgedec" <jorge...@neo.rr.comwrote:
My understanding is that I am applying the border to the same element,
CSS cascading problem

To find it, install Firefox, the Web Developer Toolbar, then look at
the effects of "View Style Information" for an element of each menu.

Simplified, it shows this:

div.vbar2 a (line 56)
{ width: 100%; border-bottom-color: green; }

html body .vbar2 a, html body .vbar1 a (line 65)
{ width: auto; }
and (for the other <div>)

html body .vbar2 a, html body .vbar1 a (line 65)
{ width: auto; }

div.vbar1 ul li a (line 46)
{ width: 100%; border-bottom-color: blue; }

Note that the CSS blocks appear to have been re-arranged compared to
their original line numberings! After specificity is taken into
account, the latest one wins.

CSS selector specificity depends (slightly) on the number of elements
involved in a selector. You've changed this enough that
"div.<classnamea" has changed to "div.<classnameul li a" and so
has gone from being _less_ specific than "html body .<classnamea"
to being _more_ specific than it. A width rule has thus changed from
width: auto; to width: 100%;

Feb 21 '07 #2

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

Similar topics

12
2265
by: Thomas Mlynarczyk | last post by:
While experimenting with Array.sort(function) I got different results from different browsers. How can that be? Shouldn't I expect identical results - given both the input array and the sort...
12
9338
by: williamc | last post by:
Is there anything wrong with having several classes with the same name in the same style sheet? Something like... div.pagedown { margin: 20px 0px 20px 0px; border-top: 1px solid #caa;...
3
6603
by: Lian Liming | last post by:
Hi, The language in my web site may be Simplified Chinese or English. I want to define different styles for each language. For each language, the http header is different. <meta name="language"...
7
2249
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
7
2857
by: Gary | last post by:
Hi i'm exploring a tutorial stylesheet which uses the following code #header ul li a { .... line-height: 0.8em !important; line-height: 1em; .... }
6
7176
by: _googlepost | last post by:
I have some CSS that goes something like this: table.TableStyle {font-family: "Helvetica", "Ariel"; background- color:white; border-collapse:collapse;} table.TableStyle COLGROUP { background-...
3
1980
by: RobG | last post by:
The link below is to a CSS selector test suite that tests 6 popular libraries: <URL: http://ajaxian.com/archives/slickspeed-css-selector-testsuite It might be of interest to some. -- Rob
3
1590
by: PtotheC | last post by:
I have a problem that I need to solve in MS Access 2000. I know how to do this in Excel. However this needs to be in Access due to a customer’s requirement. I have a list of events and what the...
1
1891
by: Alessandro | last post by:
Hi list! A quick question (and I hope a quick answer!). I have a Windows Server 2003 R2 SP2 box where MS SQL 2000 SP4 is running. I have a debian "sarge" box running apache 2.0.54-5sarge2 and...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6989
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
7157
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
7195
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
5453
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,...
1
4889
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...
0
3088
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
1400
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 ...
1
644
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.