Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What am I doing wrong with this ordered list?

Here's my site: http://www.brucegust.com/campaign/OOP/order_list.htm

Here's the tutorial I'm using: http://www.cssmojo.com/how_to_style_a_code_listing/#preview

Here's my code:

<!DOCTYPE html>
<html lang="en">
<head>
<title>Ordered List Test</title>
<style>
ol {
	background:#036 url(/img/gutter.gif) 2.3em 0 repeat-y;
	overflow:auto;
	font-family:"Courier New",Courier,mono;
	margin:0;
	padding:1em 0 1em 2.8em;
	color:#fff;
	width:90%;
}
#content ol li {
	background:#ffc;
	font-size:small;
}
#content ol code {color:#036;}
</style>
</head>

<body>

<ol>
<li><code>ol {background:#036 url(/img/gutter.gif) 2.3em 0 repeat-y;overflow:auto;font-family:"Courier New",Courier,mono;margin:0;padding:1em 0 1em 2.8em;color:#fff;width:90%}</code></li>
<li><code>ol li {background:#ffc;font-size:small;}</code></li>
<li><code>ol code {color:#036;}</code></li>
</ol>

</body>
</html>

Open in new window


I want my stuff to look like the tutorial, but all I get is that solid blue box as opposed to the blue margin and I can't figure it out.

What am I missing?
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Check the url of that image it does not look like it loads so you might have the path wrong and it cannot be found.

Cd&
Avatar of Bruce Gust

ASKER

Yo, COBOL! I corrected the URL and I'm still south of where I need to be.

In the example, the blue portion is 36 pixels across. Mine, I'm taking up the whole page with the blue color. Yet, it should be just the "<ol>" portion, right?

Where am I blowing it?
You have width of the ol set to 90% and the background color is going to fill the complete area of the ol block. Plus you have the background properties in reverse order and that be affecting the stacking order.  In the example the color #036 is specified last.  The CSS in the example is so badly written, that it is hard to folow and you will probably have a problem anytime you try and do maintenance on the page.  I generally avoid junk like that when I see the code is badly written.

Cd&
I do like the effect, though. Is there anything salvageable about the code, or can you point me in the direction of a well written example of what they're doing.

Bottom line: I want to publish my code in the context of a numbered format like what they've got at http://www.cssmojo.com/how_to_style_a_code_listing/#preview. Is it tweak-able, or can you show me a different approach?

What do you think?
The effect is basically the result of applying padding to the ol and then overlaying the color with a background color on the text in the li elements.

If I wanted to do something like that I would just create a blue background image and the use background properties to limit its width so the ol ends up with a narrow vertical band on the left side, and the use the styling in the li elements to do the alternating rows.

ol {background-color:blue; background-repeat:repeat-y;background-position:left top;}
with a 40px square image should work fine. Then you just adjust the margin-left of the ol to move it in off of the background.

Cd&
Got it!

Cd - two things: Head out to http://brucegust.com/campaign/OOP/order_list.htm and you'll see the improvements. What have I got to do to change the font color of the <li>'s? Looks great as far as the blue background and the white font, in terms of my numbers, but how can I get my text to stand out?

Also, in the example on http://www.cssmojo.com/how_to_style_a_code_listing/#preview, they use a <code> tag. That's just a CSS tool that you can use to ensure that the syntax you're documenting isn't processed as actual code, correct?
in the rule ol li you have a typo that inserted a single quote background:#ffc;' and it stops psrsing befor it gets to the color property.

The <code> tag is a formatting tag like <em> or <strong> it is generally used to make code stand out or use an alternate format.  If you want code to hold its format you can use <pre> normally white space is collapsed but inside <pre> all the white space is preserved as are the line feeds without having to use <br />

If you are going to display html code you either need to put it in a textarea, or hide the opening angle bracket with &lt; if you put <h2> in the text, the browser will treat it as a tag an turn everything following a a heading but if you use &lt;h2> then it will display <h2>

Cd&
Cd - do you smell that? It's the smell of success! We're almost there, but I'm still missing something.

Head out to http://brucegust.com/campaign/OOP/order_list.htm and you'll see where I'm at. All I want to do is change the color of the <ol>. I did correct the typo, but we're still having to endure a pesky amount of consistency between the format of the <ol> number and the color of the text in my <li> tags.

What do you think? How can I make my <li> tags black>?
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!