473,729 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

border around an A tag not wrapping around the whole box in firefox.

I'm trying to put a border around a link when the mouse rolls over it.
I've made an example below and left out the hover to keep it simple. In
IE the example below draws a box arround the image OK, in Firefox the
box drawn is one line of text in height. If I add any lines of text
inside the A tag it borders each line of text individually.

The solutions I've tried are:

putting a Div tag inside the A and using A:hover .myDiv{boder... ..}
unfortunatley this doesn't seem to work in IE

Using both A:hover and A:hover img which works in firefox full size.
Down sides are the not all of the content to be boxed it image based
and it also displays the tiny border aswell as the full sized border in
fireFox.

I'm wondering if I should use javascript instead to change the border
value, that way I can change the border on the DIV that the A is in.

Is this making sense to anyone? Anyway, if someone can work out a way
of getting the below to work in firefox and IE using A:hover instead of
A it would be greatly appreciated ( no borders when you're not
hovering).

I realise it's probably not working due to my lack of CSS knowledge.

Thanks in advance,
Mike.

####### CODE EXAMPLE HERE ########

<head>
<title>Test</title>
<style type="text/css">
<!--
img {border:none;}
A{ border: 4px dashed #99CCCC; margin: -4px; }
-->
</style>
</head>
<body>
<div class="item"><a href="#"><img src="images/notePaper.gif"
width="245" height="150" /></a></div>
</body>
</html>

Sep 12 '06 #1
3 3019
Els
mc**@hotmail.co m wrote:
I'm trying to put a border around a link when the mouse rolls over it.
I've made an example below and left out the hover to keep it simple. In
IE the example below draws a box arround the image OK, in Firefox the
box drawn is one line of text in height. If I add any lines of text
inside the A tag it borders each line of text individually.

The solutions I've tried are:
Maybe you're looking for a{display:block ;}?

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: Trockener Kecks - Paradijs
Sep 12 '06 #2
Exactly what I was looking for... Was that a RTFM moment :S.

Thanks very much for that.

Mike

Sep 12 '06 #3

mc**@hotmail.co m wrote:
If I add any lines of text
inside the A tag it borders each line of text individually.
There's a bunch of stuff involved here.

1. The content of <ais %inline;, not %block; or %flow;.
http://www.w3.org/TR/html4/struct/links.html#edef-A

This means that you can't place block elements like <divor <pinside
an <a>. If you do, then anything could happen.

It _doesn't_ mena that you can't have "lines of text" inside an <a>
though, because <bris an inline element and so it's still permitted.
You don't specify how you were achieving your "lines of text", but I
suspect you were using <prather than <br>

2. <ahas CSS display: inline; by default rather than block.
Although you can still use some "block like" CSS rendering properties
on it, such as "border", then they're not likely to work quite how you
expect. If you want <ato look like a block element, then set the CSS
display: block; property and do it properly.

In particular, bordering inline elements _should_ border each line
separately. After all, they're inline. If you want an overall border
around the whole element, you'll be wanting diaplay: block;

3. You mention IE, but you don't mention a doctype. If you have IE in
Strict rendering mode, by using a proper doctype on your HTML, then
(AFAIK) you will get the same correct behaviour as FF, even though it's
not what you want.

If you're doctype-less, then IE drops into quirks mode and deliberately
mis-renders borders on <awhen inline as if it were block, on the
assumption that this is "what you really wanted". Evil piece of crud
that it is 8-(

If you're trying to do anything width-related to <athen you'll
probably need to set a width on it. The "traditiona l" way to do this is
to set width: 100%; on the <aand control the width of its containing
element, frequently a <li>

So the real fix is to write valid HTML, to switch <ainto display:
block; rendering if that's what you're after, force IE into standards
mode, then suddenly wonder how it all became so easy to do the rest
8-)

I'm wondering if I should use javascript instead to change the border
value,
That's never the answer to anything, certainly not for presentation.
It's also more complicated and much harder to support. Fortunately you
asked in c.i.w.a.s first!

Here's an example, showing most of the variations. Go play with it.
Then remove the doctype and try viewing it again (in both IE and FF)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>Multi-line A element</title>

<style type="text/css" >

div {
margin: 1em;
width: 20em;
}

a {
border: 3px solid red;
width: 100%;
}

div.a-as-block a {
border-color: blue;
width: 100%;
display: block;
}
</style>

</head><body>
<div class="single-line" >
<a href="#" >A link</a>
</div>
<div class="with-linebreak" >
<a href="#" >Another link<br>with multiple lines</a>
</div>
<div class="with-para" >
<a href="#" >An incorrect link<p>with multiple lines</a>
</div>

<div class="a-as-block" >

<div class="single-line" >
<a href="#" >A link</a>
</div>
<div class="with-linebreak" >
<a href="#" >Another link<br>with multiple lines</a>
</div>
<div class="with-para" >
<a href="#" >An incorrect link<p>with multiple lines</a>
</div>

</div>

</body></html>

Sep 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
5141
by: Vigil | last post by:
I am trying to put a 7px border around a page. If the contents don't fill up the viewport, then the border must appear all around the viewport. If the page is larger than the viewport, then the border must wrap around the contents. Both should result in the border around the complete page, no matter the size, so that none of the bgcolor bleeds outside of it (ie. you can never see or scroll outside of the border). I would have thought this...
0
1841
by: Red | last post by:
This is apparently an ie display bug, I can't seem to figure out which ie bug this is. a 3 sided border is created by wrapping the 'inner' box in the 'middle' box and padding the 'middle' box 1px on 3 sides. It looks the same in firefox and ie. Then the same box is wrapped in yet another box with a red border on the bottom. In Firefox the 'middle' box still has padding on only 3 sides, and the red border is showing on the bottom. In...
6
15932
by: Mr. Clean | last post by:
Apparently Mozilla/Firefox doesn't support the bordercolor attribute of the table tag. Here's what I do that works in IE: <table border="1" cellpadding="2" cellspacing="0" width="380" bordercolor="#CB0017"> Now, if I add this to my CSS:
3
15345
by: David Stone | last post by:
I'm trying to apply a border to a Flash learning object, which is loaded into a page via <object>. I'm trying to use a style to put a black border around the Flash object. http://www.chem.utoronto.ca/coursenotes/analsci/chrom/column01.html http://www.chem.utoronto.ca/coursenotes/analsci/analsci.css Quick summary: <object class="bordered" ...>
8
12100
by: UJ | last post by:
I have a table with multiple cells and I want to draw a box around the entire table but not around the individual cells. How do I do that? TIA - Jeff.
2
5049
by: jonathandowns | last post by:
i'm trying to put a css border around this box, and it's not working properly in safari and firefox (works fine in IE). can anyone help me fix this? here is a grab so you can see the problem: http://www.thebrotherkite.com/grab.jpg and here is the css code: #container {
6
28096
by: Hacking Bear | last post by:
Hi, I still don't quite fully understand how to handle mixing border/margin pixel width with percentage width. In the example below, I want to place side-by-side two DIV boxes inside a box. 1. Each box takes up 50% of the parent. 2. One of the box has a border width of 1px.
0
1617
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone! I have these three questions and though to post them in a single thread: 1) I have created a textarea: <textarea id="txtCards" cols="50" rows="15" runat="server" wrap="virtual" /> which is used for user editing (typing in some info).
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.