|
|
Post a Project »
Find a Professional HTML Freelancer!
Find a Freelancer to help you with your HTML projects
| |
|
Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
08-19-2008, 03:04 PM
|
Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 24
Name: Elenor
Location: Cumming, GA
|
(Disclaimer: Of course, the coding works perfectly in Firefox. In MISE6, it actually appears as desired. (!) In MSIE7, it breaks. {sigh})
I've got an unordered list -- the bullets are graphical numbers, so each li has a class: "li-1" "li-2" etc. Some of the li's have several paragraphs within the li. If I use the <p> code around the first sentence, the sentence drops down so the graphic number is longer aligned with the top of the text. If I don't use it, then there is a bit of untagged text, which is less-than-optimal (isn't it?). The list is here: http://www.snowtao.com/cave/CSS-gst2008.htm#rumors
I'd rather NOT have to add a tag to every first para in every numbered list (across 200+ pages!)
The CSS
numb-list li {
list-style: none;
line-height: 1.2em;
}
.li-1 { /* each list item gets the numbered class */
padding: 0 0 1em 2em;
background: url(../art/no-1.gif) no-repeat left top;
margin-top: 1em;
}
The HTML:
<ul class="numb-list"> <li class="li-2"><strong>If you decide not to tell the truth, don’t pretend you’re not allowed to. </strong>
<p>Often you’re entitled to release the information.... blah blah blah .... true, there’s no easy way to rebut the false bits without confirming the true ones, and on balance you end up deciding to keep mum. </p>
<p>Okay, that wouldn’t be my call but I’m not in your shoes. But at least you shouldn’t pretend (even to yourself) that it wasn’t your choice.</p></li>
|
|
|
|
08-19-2008, 04:02 PM
|
Re: Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
|
Use a definition list (which is what it is really).
float your graphic number left in the <dt> and use <dd>s instead of paragraphs
http://www.candsdesign.co.uk/reference/html/tags/lists/
http://www.w3schools.com/html/html_lists.asp
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
|
|
|
|
08-20-2008, 01:54 PM
|
Re: Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 1,772
Name: Stephanie
Location: Oklahoma
|
Technically, you wouldn't have to have an extra <p> tag around the text inside of an <li>. The <li> tag itself encloses the items in a list. However, you are using a list a little differently. I agree with Chris that a definition list might be more suitable for this.
You could also use a list inside of a list.
The structure would be:
Code:
<ul class="numb-list">
<li class="li-2">
<ul>
<li>
<strong>If you decide not to tell the truth, don’t pretend you’re not allowed to. </strong>
</li>
<li>
Often you’re entitled to release the information.... blah blah blah .... true, there’s no easy way to rebut the false bits without confirming the true ones, and on balance you end up deciding to keep mum.
</li>
<li>
Okay, that wouldn’t be my call but I’m not in your shoes. But at least you shouldn’t pretend (even to yourself) that it wasn’t your choice.
</li>
</ul>
</li>
</ul>
|
|
|
|
08-20-2008, 07:58 PM
|
Re: Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 24
Name: Elenor
Location: Cumming, GA
|
chrishirst -- Thanks, I understand what you're suggesting -- but the thought of having to to redo a couple hundred such lists is daunting, to say the least! And I'm not sure it's accurate or better semantically to call text paragraphs definitions.
angele803 -- Thanks for your suggestion, however, I wouldn't want to turn what are actual paragraphs of text into list items -- because they are not in any way list items -- they're plain-old paragraphs that happen to be within a list. And I'd have to code the new "list items" to look like paras, and I'm not sure that's good coding.
I was thinking I could use "first-child" except MSIE doesn't handle that well (and sadly, huge, huge numbers of our visitors use MSIE).
I tried reading the W3C standard about <li>s and <p>s and it was no help. Does anyone know if it's a really bad thing to have the first "paragraph" of a <li> without a "close-code" of any kind? Or am I really compelled to turn it all into stuff it isn't actually?
Elenor
|
|
|
|
08-20-2008, 10:25 PM
|
Re: Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 1,772
Name: Stephanie
Location: Oklahoma
|
I think I see your point now.
You might be able to do this with some javascript and the DOM. I am by no means a javascript or DOM expert, but you should be able to pick out all of the <ul> with a class of numb-list. Then you should be able to identify the first paragraph inside each of those classes. Then, with javascript, you should be able to dynamically add a class or a style to all of those first paragraphs.
I am not really sure where to point you from here (especially right now since it has been a long day of a long week and my brain is exhausted!!), but maybe it gives you something to work from? Maybe someone else can elaborate? If I get some time tomorrow, I will see if I can find an example or a tutorial that can help. I am pretty sure this can be done though.
|
|
|
|
08-20-2008, 11:46 PM
|
Re: Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 9,007
Name: Tim Daily
Location: Apex, NC, US, Sol 3
|
So far as I am aware, you should not put a <p> inside a <ul>, ever; it's not semantically correct. You can change the <ul>s to <div>s and restyle accordingly; perhaps that would be easier?
tim 
|
|
|
|
08-27-2008, 09:06 PM
|
Re: Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 24
Name: Elenor
Location: Cumming, GA
|
Thanks Tim ({sigh, I think}, that's kinda what I was afraid of: not having <p>s inside <li>'s...
So, <li>s can only ever be a single line or a single paragraph/block of text?
|
|
|
|
08-27-2008, 11:26 PM
|
Re: Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
Posts: 9,007
Name: Tim Daily
Location: Apex, NC, US, Sol 3
|
A <li> must be enclosed by a <ul>, but it can have inline elements within it. Suckerfish menus, for instance, put anchor tags within the <li>, and use CSS (and sometimes javascript) to toggle whether it displays. What's important is that your markup is consistent and standards-compliant, which will make it much easier to style it to look the way you want it to.
Chris is right that a <dl> is probably your best bet, but again, you do have the option of changing to <div>s and keeping the <p>s.
tim 
|
|
|
|
|
« Reply to Using <P> inside <li>? (breaks in MSIE7, okay in MSIE6 and Firefox)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|