473,545 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

nested div stylesheet question

if I have nested div combinations, can I call
for styles only to specific nested combos?

It's 3 lists <li>, on one page, needing different styles.

<div id=list1><li> <a id="t1" href=...>main</a></li><div>

<div id=list2><li> <a id="t1" href=...>main</a></li><div>

<div id=list3><li> <a id="t1" href=...>main</a></li><div>
I need the <li> in menu1 to be 10% width; and the
<li> in menu2 and menu3 to be 100% width.
How would I call this one?

#list1..li...?? ???? {
width:10%
}

#list2+3,li???? ?? {
width:100%
}

Thanks,
Theo
Jul 21 '05 #1
14 6594
On Mon, 21 Feb 2005 14:48:29 -0600, theo <th**@nospam.co m> wrote:
if I have nested div combinations, can I call
for styles only to specific nested combos?

It's 3 lists <li>, on one page, needing different styles.

<div id=list1><li> <a id="t1" href=...>main</a></li><div>

<div id=list2><li> <a id="t1" href=...>main</a></li><div>

<div id=list3><li> <a id="t1" href=...>main</a></li><div>

For one, this is not what nested means. Nested would be like
<div>
<div>
<div></div>
</div>
</div>

Like the first div embraces both others and the second div embraces just the
middle one.

Secondly, did you try validate that markup? I bet you it won't. Putting list
items in the wild like that isn't smart. List items are elements that should be
contained in either an ordered list or an unorderd list, like

<ul>
<li></li>
<li></li>
<li></li>
</ul>
I need the <li> in menu1 to be 10% width; and the
<li> in menu2 and menu3 to be 100% width.


You've set something of a parent element up with a width, so the 10% and 100%
actually can relate to that, did you?

I don't see a menu1 anywhere in the code you provided, so I have to guess some
here. My guess is, this is what you are trying to do (don't use a space as a
starting character; set an appropriate padding on the element if you need it):

<ul id="menu">
<li class="narrow"> <a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>

ul#menu { width:$length; }

#menu li { width:100%; }

#menu li.narrow { width:10%; }

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
Jul 21 '05 #2
"theo" <th**@nospam.co m> wrote:
if I have nested div combinations, can I call
for styles only to specific nested combos?
Yes if they have different class and/or id a$ttributes.
It's 3 lists <li>, on one page, needing different styles.

<div id=list1><li> <a id="t1" href=...>main</a></li><div>

<div id=list2><li> <a id="t1" href=...>main</a></li><div>

<div id=list3><li> <a id="t1" href=...>main</a></li><div>
1. You open six divs but don't close any of them. Are the final <div>s
on each line meant to be </div>s?
2. Your code is invalid. <li> can only be a child of <ul>, nothing
else.
3. Values for id must be unique within the page. You can not have
three different id="t1" in the same page.
I need the <li> in menu1 to be 10% width; and the
<li> in menu2 and menu3 to be 100% width.


Assuming that your code really looks something like this:

<ul id=list1><li> <a class="t1" href=...>main</a></li></ul>
<ul id=list2><li> <a class="t1" href=...>main</a></li></ul>
<ul id=list3><li> <a class="t1" href=...>main</a></li></ul>

#list1 li {width: 10% ;}
#list2 li, #list3 li {width: 100%;}

Though you're probably better off setting the widths of the <ul>s
rather than the <li>s but that may depend on your real code and the
rest of your styles.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 21 '05 #3
On Mon, 21 Feb 2005 21:00:30 +0000, Steve Pugh <st***@pugh.net > wrote:
"theo" <th**@nospam.co m> wrote:
<div id=list1><li> <a id="t1" href=...>main</a></li><div>

<div id=list2><li> <a id="t1" href=...>main</a></li><div>

<div id=list3><li> <a id="t1" href=...>main</a></li><div>


1. You open six divs but don't close any of them. Are the final <div>s
on each line meant to be </div>s?


I never even saw that.

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
Jul 21 '05 #4
On Mon, 21 Feb 2005 14:48:29 -0600, "theo" <th**@nospam.co m> wrote:
if I have nested div combinations, can I call
for styles only to specific nested combos?
Yes; provided that you do things the _right_ way from the start.
It's 3 lists <li>, on one page, needing different styles.
That's Ok so far, but not for very long as we shall see...
<div id=list1><li> <a id="t1" href=...>main</a></li><div>
Error #1: <li> elements must be contained within either of a <ul> or a
<ol> element. You can not put an <li> element directly in a <div>
element.
<div id=list2><li> <a id="t1" href=...>main</a></li><div>
Error #1: (same as #1 above)
Error #2: each assigned value for an 'id' must be unique within an HTML
document instance and you have already used 't1' in the previous line.
<div id=list3><li> <a id="t1" href=...>main</a></li><div>
Error #1: (same as #1 above)
Error #2: (same as #2 above)

Generic error: I find it hard to believe that you can find some logic in
a set of lists that has only one entry per list.

Generic doubt: I find it hard to see why the use of 'id' should be
preferable here, to me it looks like a clear case for the 'class'
attribute.
I need the <li> in menu1 to be 10% width; and the
<li> in menu2 and menu3 to be 100% width.


Fix your markup to be valid an logically correct first, then come back
with an example URL for your test page and we could take it from there.

--
Rex
Jul 21 '05 #5
> You've set something of a parent element up with a width, so the 10% and
100%
actually can relate to that, did you?

I don't see a menu1 anywhere in the code you provided, so I have to guess some here. My guess is, this is what you are trying to do (don't use a space as a starting character; set an appropriate padding on the element if you need it):
<ul id="menu">
<li class="narrow"> <a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>

ul#menu { width:$length; }

#menu li { width:100%; }

#menu li.narrow { width:10%; }

Barbara,
I truly appreciate your time and energy here, as I
didn't have a clue with regard to how to accomplish this.

So, once you add a class to the <ul>, you style it by
calling the ul#menu {}

The <li> is also styled, but you called that differently,
with #menu li.narrow instead.

I'm going to have to find the manual! Are you saying that
I should not style the <ul> or the <li>, being parent elements,
but that I should add class and style the new class? Or, are
you adding a class only to those which need to be different?

If I have a:

<div id="menu1">
<ul>
<li><a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>
</div>

<div id="menu2">
<ul>
<li><a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>
</div>

is it kosher to seperate and style the <li> with:

#menu1 li {width:10%;}
#menu2 li {width:100%}?

Theo



Jul 21 '05 #6
Error #2: each assigned value for an 'id' must be unique within an HTML
document instance and you have already used 't1' in the previous line.


I can't use id multiple times? Didn't know that. All that I read about
id was that it is the same as a class, but used in cases where javascript
was present, being that javascript also uses classes. It was a brief
tutorial

Theo
Jul 21 '05 #7
On 21 Feb 2005 22:03:55 +0100, "Barbara de Zoete"
<b_********@hot mail.com> wrote:
On Mon, 21 Feb 2005 21:00:30 +0000, Steve Pugh <st***@pugh.net > wrote:
"theo" <th**@nospam.co m> wrote:
<div id=list1><li> <a id="t1" href=...>main</a></li><div>
<div id=list2><li> <a id="t1" href=...>main</a></li><div>
<div id=list3><li> <a id="t1" href=...>main</a></li><div>


1. You open six divs but don't close any of them. Are the final <div>s
on each line meant to be </div>s?


I never even saw that.


<AOL>Me too</AOL>
sad to say I feel a bit embarrased :-)

--
Rex
Jul 21 '05 #8
On Mon, 21 Feb 2005 16:08:07 -0600, theo <th**@nospam.co m> wrote:
<ul id="menu">
<li class="narrow"> <a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>

ul#menu { width:$length; }

#menu li { width:100%; }

#menu li.narrow { width:10%; }

So, once you add a class to the <ul>, you style it by
calling the ul#menu {}


In a stylesheet, a selector starting with a # means it is an id. Starting with a
.. (dot) means it is a class. You can use a class as many times in a page as you
wish. An id however, you can only use once in a page. Like a social security
number. There can only be one navigation_menu , one page_header, one main_content
et cetera. Choosing an id over a class also has impact as to how styles are
cascaded.

inline styles wins over anything (except if no css capability is present
ofcourse)
the rest of the order is: id's
classes with !important added to them
normal classes
general styles (element is also the selector)

Need to know, if you want to be able to make proper use of css.
The <li> is also styled, but you called that differently,
with #menu li.narrow instead.

Well, yes. You can use multiple classes on an element (only one id) in you
markup. In your css you can single out a certain class or id by following the
line of descendents.
With elements you can style, as a general rule

body { styles }

p ( styles }

div { styles }

and then create specific styles for paragraphs that are nested inside a div for
example

div p { styles, different from the previous p }

Those will only apply to paragraphs that are descendents of div's.
I'm going to have to find the manual!
My thought exactly. Here your are:
For starting: <http://www.w3.org/MarkUp/Guide/Style.html>
The standards: <http://www.w3.org/TR/2002/WD-CSS21-20020802/cover.html>
For validation: <http://jigsaw.w3.org/css-validator/>
Are you saying that
I should not style the <ul> or the <li>, being parent elements,
but that I should add class and style the new class?
Doesn't really parse properly what you just said. I was just wild guessing my
way around, because I had not a really clear picture of what you were needing or
wanting.
Or, are
you adding a class only to those which need to be different?

You can style all elements you use directly. That is very good practice, to do
that. Then if something needs a style of its own, you can add a class to the
element and give it styles through use of that class, or you can nest the
element inside a parent with a class or id and style it using that. Depends on
the context which is preferred.
If I have a:

<div id="menu1">
<ul>
<li><a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>
</div>

If you have only one menu, you could just as easily add the id to the unordered
list and style that directly.
<div id="menu2">
<ul>
<li><a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>
</div>

is it kosher to seperate and style the <li> with:

#menu1 li {width:10%;}
#menu2 li {width:100%}?


If it stays as simple as this, you can just as easily put those id's on the
ul's. You don't need those divs then. Saves code. Keeps things clean and clear.

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
Jul 21 '05 #9
"Barbara de Zoete" <b_********@hot mail.com> wrote:
inline styles wins over anything (except if no css capability is present
ofcourse)
the rest of the order is: id's
classes with !important added to them
You can apply !important to any style rule not just to ones selected
with a class.
!important also moves the rule higher in the cascade (above all other
author rules but below use rules with !important) so it will beat an
inline style.
normal classes
general styles (element is also the selector)


A brief list of rules should have gone (ignoring user style sheets):
1. !important
2. Inline style.
3. ID
4. Class, pseudo-class (such as :link) and other attributes (such as
[type=text])
5. Elements and pseudo-elements
6. Any other selector (such as the universal selector *)

However, in combination it's a lot more complex than that.
http://www.w3.org/TR/CSS21/cascade.html#specificity
Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 21 '05 #10

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

Similar topics

4
2660
by: Dthmtlgod | last post by:
Could someone please look at my code below, I am trying to nest a couple of if statements together and it is not working. I think I am close. if len(rsMove("MonitorID1")) > 0 and len(rsMove("MonitorID2")) > 0 then response.write ("Dual Monitors") else if len(rsMove("MonitorID1")) > 1 and len(rsMove("MonitorID2")) = 0 then response.write...
7
1773
by: Alfonso Morra | last post by:
I have a class that contains a nested class. The outer class is called outer, and the nested class is called inner. When I try to compile the following code, I get a number of errors. It is not obvious to me, where I'm going wrong (the compiler messages do not seem to make much sense). here is the code: outer class declared as ff in...
3
6433
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too...
1
3151
by: Bojesphob | last post by:
Can someone help? I have a nested repeater in which I wish to format one of the bits of data in currency. I know that the code for the regular repeater (which works fine in parent) is databinder.eval(Container.DataItem, "Net", "{0:c}") . BUT I use that code in the nested repeater and IT DOES NOT WORK!!!! In that code I have DataBinder.Eval...
4
262
by: Nedu N | last post by:
how to apply a stylesheet for the entire web applciation in ASP.NET? Thanks
0
270
by: Scott | last post by:
I am very new to stylesheets, but would like to use them. I have what is hopefully a real easy question to answer. We have spent a lot of time designing quite a few .NET web pages for a new web site. We never used a stylesheet when we did all of this. Now, we would like to incorporate a style sheet into the web site design. Rather than...
7
1297
by: biner.sebastien | last post by:
I have a problem understanding the scope of variable in nested function. I think I got it nailed to the following example copied from Learning Python 2nd edition page 205. Here is the code. def f1() : x=88 f2() def f2() : print 'x=',x f1()
1
984
by: dogbert1793 | last post by:
Can a ref class have a definition for a native class nested in it? The ref class would also have a native pointer to an instance of the nested class (which I know is ok).
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
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
4960
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
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
0
722
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.