473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Strange css problem (bug?)

Hi,

I'm developing a asp.net application and ran into a strange css problem.

I want all my links to have a dashed underline and when they are
hovered, it must change to a solid line. Sounds simple, but it's not
working.

I've cooked down my output code to show you what I mean. If you run the
code below, there's no line under the link, but if you either remove the
<!DOCTYPE...> line or the body-part of the css decleration, everything
works fine.

Here's my code (watch for wrappings):

----------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Strange</title>
</head>
<body>
<style>
<!--
body
{
font-family: verdana, arial, helvetica, sans-serif;
}
a:link, a:visited
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px dashed #d32525;
text-decoration: none;
}

a:hover
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px solid #d32525;
text-decoration: none;
}

-->
</style>

<a href="http://www.microsoft.com/">This is just a link</a>

</body>
</html>

----------------------------------------------------------------------

Any idea???????

I also found out, if I put a <p>&nbsp;</p> below the <a href...> in the
code above, everything works fine.

I'm confused!!!!!

HHHHEEELLLPPPPP! :o)

Thank you in advance.

M O J O
Aug 28 '05 #1
7 1640
M O J O skrev:
I also found out, if I put a <p>&nbsp;</p> below the <a href...> in the
code above, everything works fine.


In xhtml text must be in a blockelement, so that's why it works
without doctype.

<p><a href="http://www.microsoft.com/">This is just a
link</a></p>
--
Knud
Topposter du svar, så ryger du på min ignoreringsliste.
Svar under det du citerer og citer kun det du svarer på - tak.
http://usenet.dk/netikette/citatteknik.html
Aug 28 '05 #2
Knud Gert Ellentoft wrote:
In xhtml text must be in a blockelement


No, that's Strict (HTML 4.01 Strict and XHTML 1.0 Strict). Transitional DTDs
allow text to be contained directly within the <body>, (Not that anybody
should be using Transitional in this day and age).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 28 '05 #3
M O J O wrote:

Hi,

I'm developing a asp.net application and ran into a strange css problem.

I want all my links to have a dashed underline and when they are
hovered, it must change to a solid line. Sounds simple, but it's not
working.

I've cooked down my output code to show you what I mean. If you run the
code below, there's no line under the link, but if you either remove the
<!DOCTYPE...> line or the body-part of the css decleration, everything
works fine.

Here's my code (watch for wrappings):

----------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Strange</title>
</head>
<body>
<style>
<!--
body
{
font-family: verdana, arial, helvetica, sans-serif;
}

a:link, a:visited
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px dashed #d32525;
text-decoration: none;
}

a:hover
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px solid #d32525;
text-decoration: none;
}

-->
</style>

<a href="http://www.microsoft.com/">This is just a link</a>

</body>
</html>

----------------------------------------------------------------------

Any idea???????

I also found out, if I put a <p>&nbsp;</p> below the <a href...> in the
code above, everything works fine.


I copied your sample into a new HTML file and tried it with Mozilla
Suite 1.7.11. It works exactly as you describe your intent: There
was a dashed underline for the link until I hovered my cursor over
it, when it changed to a solid underline.

By the way, you have defined font-family for body. You don't have
to repeat the definition for the anchors unless you are using a
different set of fonts for them.

--

David E. Ross
<URL:http://www.rossde.com/>

I use Mozilla as my Web browser because I want a browser that
complies with Web standards. See <URL:http://www.mozilla.org/>.
Aug 28 '05 #4
"M O J O" wrote in message news:43***********************@dreader1.cybercity. dk...
Hi,

I'm developing a asp.net application and ran into a strange css problem.
no bug, you need to fix a few things here.
I want all my links to have a dashed underline and when they are
hovered, it must change to a solid line. Sounds simple, but it's not
working.

I've cooked down my output code to show you what I mean. If you run the
code below, there's no line under the link, but if you either remove the
<!DOCTYPE...> line or the body-part of the css decleration, everything
works fine.

Here's my code (watch for wrappings):

----------------------------------------------------------------------
first you declare it to be XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
then, I think something is missing in <html> like
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
then you go ahead and redeclare the content to be plain html and don't end the "empty tag" with /> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Strange</title>
</head>
<body>
you want style, but style belongs in the <head> and you don't add the type <style> as in
<style type="text/css">
then, by your document wanting to be XHTML, you need to define the style data block
<!--/*--><![CDATA[/*><!--*/
instead of just <!-- body
{
font-family: verdana, arial, helvetica, sans-serif;
}
a:link, a:visited
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px dashed #d32525;
text-decoration: none;
}

a:hover
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px solid #d32525;
text-decoration: none;
}

and end it with
/*]]>*/--></style>
instead of just -->
</style>

<a href="http://www.microsoft.com/">This is just a link</a>

</body>
</html>

---------------------------------------------------------------------- Any idea???????
http://www.hixie.ch/advocacy/xhtml (Sending XHTML as text/html Considered Harmful)
I also found out, if I put a <p>&nbsp;</p> below the <a href...> in the
code above, everything works fine.

I'm confused!!!!!

HHHHEEELLLPPPPP! :o)

Thank you in advance.

M O J O


so, after the corrections (btw, several things I added are optional ;-) :

<?xml version="1.0" encoding="windows-1252"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=windows-1252" />
<title>Strange</title>
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
body
{
font-family: verdana, arial, helvetica, sans-serif;
}
a:link, a:visited
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px dashed #d32525;
text-decoration: none;
}

a:hover
{
font-family: verdana, arial, helvetica, sans-serif;
color: #d32525;
border-bottom: 1px solid #d32525;
text-decoration: none;
}

/*]]>*/--></style>

</head>
<body>

<a href="http://www.microsoft.com">This is just a link</a>

</body>
</html>

Aug 28 '05 #5
M O J O:
</head>
<body>
<style>
<!--


You're kidding, right?
Aug 28 '05 #6
Robi wrote:

<body>
<a href="http://www.microsoft.com">This is just a link</a>
</body>

As Knud observed, a link is an inline element. XHTML does not like
inline elements floating around without containment. So:

<body>
<p><a href="http://www.microsoft.com">This is just a link</a></p>
</body>

Also I was impressed by the OP's ability to cram so many errors into so
little code.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Aug 29 '05 #7
Christoph Päper <ch**************@nurfuerspam.de> wrote:
M O J O:
</head>
<body>
<style>
<!--


You're kidding, right?


Looks like your regular google search result page...
Aug 29 '05 #8

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

Similar topics

20
by: Markus Sandheide | last post by:
Hello! Execute these lines: int x = 1; x = x > 2345678901; You will get: x == 1 with Borland C++ Builder
5
by: Hatul Shilgy | last post by:
Hi I'm facing a very strange problem here. My code looks like this if(A == null return doSomethingWith(A.b) When I run my code (in debug mode), I get a NullReferenceException -- and on...
10
by: Trapulo | last post by:
Why Now.Date.Subtract(New Date(2000, 1, 1)).Days returns 731529?? It is a too big value a think! I aspect something as 1030-1100....
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
3
by: Arnold Schrijver | last post by:
I wrote a program that draws items to the screen and maintains a set of Offset values. There was a bug in the code, because objects were positioned wrongly. While debugging I found some peculiar...
6
by: Hannibal111111 | last post by:
I am getting a strange situation with a .NET 1.1 web application that we have deployed. I have made an update to a code behind page in 1 file, and then made an update to another code behind page. ...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
4
by: kj | last post by:
I'm running into a strange seg fault with the module cjson. The strange part is that it does not occur when I run the code under Emacs' Pydb. Here's an example: import sys, cjson d1 =...
6
by: jdmuys | last post by:
Hi, I have a strange bug in my code, which I managed to reduce to the tiny C++ program below. The compiler reject the "class1<Type>::insideStruct *p2;" declaration with the following error...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.