Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Differences in IE's display of <ul>'s 1

Status
Not open for further replies.

Jen53403

Programmer
Jul 17, 2006
22
I am teaching myself HTML and CSS. Can anyone tell me why IE puts an extra line between list items in the product-tabs list in index.html but not in test.html? Why does the list in index.html display correctly in Firefox but not IE, and how can I fix that? (I want the page to look like it does in Firefox.) My first thought is that there's something missing in my CSS.

Also, is absolute positioning a good idea, or should I be using another method for my layout, and what method would that be?

Also, why does IE give me a "content blocked" notification for my Javascript code? This only started after I added the mouseOver() and mouseOut() methods. Again, IE does this but Firefox does not.

index.html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "[URL unfurl="true"]http://www.---.com/index.html">[/URL]
<html>
<head>
	<title>--- co.</title>
	<meta name="description" content="---">
	<meta name="keywords" content="---">
	<script type="text/javascript">
	function mouseOver(prod)
	{
		document.display.src = "product_box/" + prod + ".bmp";
	}
	function mouseOut()
	{
		document.display.src = "product_box/all_products.bmp";
	}
	</script>
	<style type="text/css">
		<!--
		#title
		{
			position: absolute;
			top: 0px;
			left: 0px;
		}

		#nav-bar
		{
			position: absolute;
			top: 158px;
			left: 0px;
		}
		#nav-bar ul
		{
			margin: 0px;
			padding: 0px;
			list-style: none;
		}
		#nav-bar li
		{
			display: inline;
		}
		#nav-bar li a
		{
			display: block;
			float: left;
			width: 131px;
			height: 24px;
			border: 1px solid #006;
			text-align: center;
			color: #006;
			line-height: 24px;
			font-size: 16px;
			font-family: serif;
			background: #d0ddfd;
		}
		#nav-bar li a:hover
		{
			background: #b0bdcd;
			color: #000;
			border-color: #000;
		}
		/* Hide from IE5-Mac \*/
		#nav-menu li a
		{
			float: none
		}
		/* End hide */

		#news-box
		{
			position: absolute;
			top: 184px;
			left: 0px;
			margin: 0px;
			padding: 0px;
			width: 264px;
			height: 400px;
			color: #000;
			font-size: 16px;
			background: #ccc url(---.gif) center no-repeat;
			list-style: none;
			font-family: serif;
			text-align: left;
			border: 1px dashed #006;
		}
		.head
		{
			font-size: 24px;
			color: #006;
			line-height: 26px;
			text-indent: 80px;
			font-weight: bold;
		}
		.content
		{
			font-size: 16px;
			color: #000;
			margin-left: 20px;
			font-weight: normal;
		}

		#product-tabs
		{
			position: absolute;
			top: 224px;
			left: 264px;
			color: #000;
			font-family: serif;
			font-size: 20px;
			line-height: 0px;
		}
		/* Hide from IE5-Mac \*/
		#product-tabs
		{
			line-height: 26px;
		}
		/* End hide */
		#product-tabs ul
		{
			list-style: none;
		}
		#product-tabs li a
		{
			text-align: left;
			display: block;
		}

		#product-images
		{
			position: absolute;
			top: 184px;
			left: 438px;
		}
		//-->
	</style>
</head>

<body>
   <div id="title">
      <img src="title800x158.jpg" alt="--- co.">
   </div>
	<div id="nav-bar">
	  <ul>
	  <li><a href="index.html">Home</a></li>
	  <li><a href="services.html">Services</a></li>
	  <li><a href="technical.html">Technical</a></li>
	  <li><a href="product_guide.html">Product Guide</a></li>
	  <li><a href="new_products.html">New Products</a></li>
	  <li><a href="contact_us.html">Contact Us</a><li>
	  </ul>
	</div>
	<div id="news-box">
		<p class="content"><span class="head">News:</span><br>- News item 1.
		<br>- News item 2.</p>
	</div>
	<div id="product-tabs">
		<ul>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('temp')" onmouseout="mouseOut()">Temperature</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('pressure')" onmouseout="mouseOut()">Pressure</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('flow')" onmouseout="mouseOut()">Flow Meters</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('sanitary')" onmouseout="mouseOut()">Sanitary</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('controls')" onmouseout="mouseOut()">Controls</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('valves')" onmouseout="mouseOut()">Valves</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('pneumatics')" onmouseout="mouseOut()">Pneumatics</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('heat_exchange')" onmouseout="mouseOut()">Heat Exchangers</a></li>
		</ul>
	</div>
	<div id="product-images">
		<img src="product_box/all_products.bmp" alt="product images" name="display">
	</div>
</body>
</html>
test.html:
Code:
<style type="text/css">
		<!--
		#product-tabs
		{
			position: absolute;
			color: #000;
			font-family: serif;
			font-size: 20px;
			list-style: none;
		}
		#product-tabs li a
		{
			text-align: left;
			display: block;
		}
		//-->
</style>
<html>
<ul id="product-tabs">
<li>li 1</li>
<li>li 2</li>
<li>li 3</li>
</ul>
</html>
Thanks!
 
1) The reason that you don't get the spaces between in test.html is because you aren't putting the anchors inside of your list items like you are in index.html

if you do:
Code:
<style type="text/css">
        <!--
        #product-tabs
        {
            position: absolute;
            color: #000;
            font-family: serif;
            font-size: 20px;
            list-style: none;
        }
        #product-tabs li a
        {
            text-align: left;
            display: block; 
        }
        //-->
</style>
<html>
<ul id="product-tabs">
<li><a href="[URL unfurl="true"]http://www.google.com">li[/URL] 1</a></li>
<li><a href="[URL unfurl="true"]http://www.google.com">li[/URL] 2</a></li>
<li><a href="[URL unfurl="true"]http://www.google.com">li[/URL] 3</a></li>
</ul>
</html>

You see that the whitespace between list items appears again. The thing that's doing this - display:block; on the anchor style definition. Any reason in particular that you're doing this? It shouldn't be needed. Remove it from the style for the anchors and you should get the look that you want.

2) Absolute positioning is not the preferred method for layout for most web developers. Try googling for "HTML liquid layout" to learn more about this.

3) onmouseover and onmouseout are 2 javascript event handlers - try disabling javascript and you'll see that they cease to function correctly. When SP2 was released for windows XP this was introduced, it's to protect you from possible security breaches. You can disable this check on your machine for local files - I don't remember exactly where the option is, but I turned it off a long time ago.

-kaht

Looking for a puppy?

[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
 
Just a question. Do you have your own website URL in the doctype? It looks like you're poitning to an html file instead of a dtd file. That will surely throw off IE and cause unexpected behaviour.
 
I'm using display: block because otherwise the product-images pic switches back to the default (all_products) pic for a split second as the mouse moves between the list items. That obvously only works on Firefox as I intended, though. Is there another way to achieve the mouseover effect that doesn't use Javascript and/or doesn't trigger IE's activeX control?
 
IE's warning box only appears in the local pages when the warning is only about a little javascript. When the page will be online, you will not see this little warning. Coming back to my original question, did you have a wrong doctype declaration? Did you fix it?
 
I don't understand why IE would only warn me about Javascript in a local page and not one online. It seems to me that a page online could do a lot more damage to me than one located on my hard drive. As for doctype declarations, I really have no clue if I did that right. I mostly just copied it from a web tutorial that did a poor job explaining what it was for. No, I haven't fixed it yet. Am I supposed to write a .dtd file, and what would it contain? The actual declaration has the company's site URL in place of the was this correct? And I was also wrong about the display: block thing; it doesn't make the mouseovers any smoother like I thought. And removing the display: block from my CSS did not fix the problem with IE, as kaht said it would. Can I use a line-height type attribute to control this? Thanks for the help.
 
I don't understand why IE would only warn me about Javascript in a local page and not one online. It seems to me that a page online could do a lot more damage to me than one located on my hard drive.

I agree. I just checked - do disable that setting do the following:
[ol][li]Tools[/li]
[li]Internet Options[/li]
[li]Advanced Tab[/li]
[li]Scroll down near the bottom to the section labeled Security[/li]
[li]Click the checkbox on the option "Allow active content to run in files on My Computer"[/li]
[/ol]

That will stop that message from popping up when you run a local html file that has javascript in it.

-kaht

Looking for a puppy?

[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
 
As for the doctype, you should simply point the url to an existing doctype on the w3 servers. Look here for a list of valid doctypes to use. This is your first step, because with a valid doctype, IE will use standards mode (or as near standards mode as IE is prepared to go) as opposed to the quirks mode. And the difference is huge -- you might realize most problems went away by just having a doctype. That is why I have not yet touched other issues yet -- until we make sure IE is within standards and the problems are still there, it's no point debugging them.
 
Vragabond, I followed your link and replaced my doctype with the following one:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"Unfortunately, this did not fix my problem, and IE still leaves an extra line between links in the product tabs.

I read on the W3C page that I should have two other lines similar to these at the top of my document:
<?xml version="1.0" encoding="utf-8"?>
<html xmlns=" xml:lang="en" lang="en">
Is this really necessary, what does it accomplish, and how do I know what encoding I'm using?

Also, what does this mean (from the bottom of the W3C page):
"List of DTDs for the CSS validator.
Authoring tools MUST NOT use the following list."

Thanks again.
 
P.S. I just realised that kaht's suggestion of deleting the display:block from the product-tabs li a attributes now fixes my problem, after I fixed the doctype declaration. Sorry if I confused anyone. There are still minor differences between IE's display and Firefox's display of the page, but I think I can live with them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top