Solved

Control <span> width in IE and FF

Posted on 2010-08-15
3
424 Views
Last Modified: 2012-06-21
I'm editing someone else's code to insert headings on colored rectangle backgrounds, that are 3 rows deep and NOT to go the full width of the table cell.

As the code below shows, I've used <span> and multiple &nbsp; to complete the create this effect. It seems an amateurish way to go about it [I'm not a CSS expert] but it works in IE8. The right hand sides of each row line up nicely. However, in FireFOX the same code produces a ragged right hand side to the rectangle with each row a different length. [Apple Safari could be a problem too.]

As an alternative I've tried using a <div> style but I have trouble limiting its height, and limiting its width to less than the table cell width.
<td width="311" class="column2">
      <table border="0" cellspacing="0" cellpadding="0" width="301">
         <tr> 
          <td height="50" align="left" valign="top" bgcolor="#ffcc00"> 

	<p><span style="color: #FFFFFF; background: #666666; height:17">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
              <b>TOP OVERALL</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </span></p>

Open in new window

0
Comment
Question by:NEILPH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 33442550
Is this anywhere close to what you want?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Untitled</title>
</head>
<body>

      <table border="0" cellspacing="0" cellpadding="0" width="301">
         <tr> 
          <td style="background-color: #ffcc00;height: 50px;padding: 16px;"><b>TOP OVERALL</b></td></tr>
</table>
</body>
</html>

Open in new window

0
 
LVL 7

Assisted Solution

by:jhp333
jhp333 earned 250 total points
ID: 33442632
How about this?
<!DOCTYPE html>
<table><tr>
	<td style="width:311px;background-color:#ffcc00;vertical-align:top" class="column2">
		<p style="width:95%;color:#FFFFFF;background:#666666;text-weight:bold">
			<br>
			TOP OVERALL<br>
			<br>
		</p>
	</td>
</tr></table>

Open in new window

0
 

Author Closing Comment

by:NEILPH
ID: 33442905
Thanks guys. Below is what I ended up doing. It's a bit from both of you plus allowing for other factors on the page.

     
         
         
                  TOP OVERALL

               

 
0

Featured Post

SendBlaster Pro 4 - Bulk Email Sending Software

SendBlaster 4 Pro - Best Bulk Emailing Sending Software
Automatic Subscribe / Unsubscribe Processing
Great for Newsletters & Mass Mailings
Optional HTML & Text Composition
Integration with Google Features
Built in Spam Score Checking
Free Professional Templates - Feature Packed!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question