Current location: Hot Scripts Forums » General Web Coding » CSS » This is a half and half HTML/JavaScript question. [DIV vs SPAN]


This is a half and half HTML/JavaScript question. [DIV vs SPAN]

Reply
  #1 (permalink)  
Old 11-23-06, 03:07 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
This is a half and half HTML/JavaScript question.

Well i was trying to figure out a way so that when a user click on a item with in the table it will go to a link. So far i have just done the work around of mouse over on a <a></a> and then altering the background of a <td></td>

Now i can't put the onmouseover="changeBg()" in the <td> tag because it does not work on all browsers. But when i try to put it like so...

Code:
<td height="21" valign="middle">
<div onmouseover="changeBg()">The link</div>
</td>
The DIV takes the shape of 100% width and what ever the height of the TEXT is, not the <TD>. So i figured ill try and make the height of the div 21 pixels, but i run into the problem of the text within the DIV valigning to the top and not middle and i dont know how to correct that.

The only other way i can think abou doing this is by adding another table with in the <TD> like so...

Code:
<td height="21" valign="middle">
<div onmouseover="changeBg()">
<table height="21" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
The link
</td>
</tr>
</table>
</div>
</td>
Now the <DIV> will wrap around the table but i just added 6 extra lines of html and i would have to mulitiply that per <TD>. Is there a common solution to this problem im missing?
__________________
"BTW, I can't program at all the only thing I figured out is how to upload templates to my server."
Reply With Quote
  #2 (permalink)  
Old 12-03-06, 01:52 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
The <div> tag is a block type element. That means it will always have a default width of 100% and "align" on the page like a big block and push everything else on that row above or below itself.

Try using a <span> tag instead, it's an inline type element. That means it will align with the rest of the contents without pushing things around unless it won't fit on that row. It also has a default width set to auto I believe, making it no larger than its contents.

Will move this to the CSS section.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
$1, Half Page Ad, 12 Months Cagedweb General Advertisements 0 09-26-05 02:19 PM


All times are GMT -5. The time now is 01:58 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.