Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to control distance with CSS in span tag

Posted on 2006-06-22
3
Medium Priority
?
1,227 Views
Last Modified: 2011-09-20
hello, I made up a span tag to make image links in a row. But I cannot control distance between a image and another image. Please advise me how to control with CSS. browsing enviroment I.E and FireFox

++main.html++
<table width="600">
<tr>
<td>
<span class="footer_img1">
<a href="a.html"><img src="a.jpg" border="0"><a>
<!-- I'd like to change the distance here-->
<a href="b.html"><img src="b.jpg" border="0"><a>
<!-- I'd like to change the distance here-->
<a href="c.html"><img src="c.jpg" border="0"><a>
<!-- I'd like to change the distance here-->
<a href="d.html"><img src="d.jpg" border="0"><a>
<!-- I'd like to change the distance here-->
<a href="e.html"><img src="e.jpg" border="0"><a>
</span>
</td>
</tr>
</table>

++detail.css++
CSS code belows

.footer_img1 {
      margin-left: 11px;
      height: 20px;
      width: 143px;
}

B.W, portal123
0
Comment
Question by:portal123
3 Comments
 
LVL 8

Assisted Solution

by:KennyTM
KennyTM earned 1000 total points
ID: 16958601
Set padding: or margin: on the <img>'s.
0
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 1000 total points
ID: 16958738
width and height do not apply to non-replaced inline elements.
so, you'll need to set them on the images (also use CSS to specify the border):

span.footer_img1 img {
     height: 20px;
     width: 143px;
     border: none;
}

then you can use a margin on the <a>'s to control the spacing, but you'll have some additional space between the <a>'s due to the space-characters that separate them (space character = white space, tab, new line, line feed).
you can hide those space if you want using some class.
also, the WCAG says you sould separate your linhks by at least one non-space-character.
you can kill two birds with one stone, using this technique:

<span class="footer_img1">
<a href="a.html"><img src="a.jpg"></a><span class="spacer"> |
</span><a href="b.html"><img src="b.jpg"></a><span class="spacer"> |
</span><a href="c.html"><img src="c.jpg"></a><span class="spacer"> |
</span><a href="d.html"><img src="d.jpg"></a><span class="spacer"> |
</span><a href="e.html"><img src="e.jpg"></a>
</span>

span.footer_img1 span.spacer {
     display: none;
}

span.footer_img1 a {
     margin-left: 11px;
}
0
 

Author Comment

by:portal123
ID: 16958858
Both Works, Thanks a lot  => A++;

~~~~~ portal123 ~~~~~~
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

971 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