views:

60

answers:

3

The problem:

alt text

Here is what I do

body {
    border: 0;
}

as was suggested here: Removing border from WebBrowser control

But this only works when we use the following doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

When doctype is changed to

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

the nasty border won't go away!

But I need the XHTML doctype in order for "position: fixed" to work in IE.

Any suggestions?


The code:

HTML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
    <title>Borders, Go Away!</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
  </body>
</html>

CSS:

body {
    border: 0;
}
A: 

I think it's due to inheritance, you should use border:0 for each element you want to remove borders.

MatTheCat
In my code I only have body element and "border: 0" won't work on it.
Vitaly
body has not default margin, I don't understand what you want.
MatTheCat
Uploaded a picture that illustrates the problem. The border is not that visible, you might say, but it really doesn't fit in when you embed the browser in your desktop application.
Vitaly
Do you have tried html {border:0;} ?
MatTheCat
Just did, html {border: 0;} doesn't work either.
Vitaly
A: 

border isn't inherited, so setting it at the body as per your example will only affect the border style of the body element itself.

If you want everything to lose its border by default, you should use * which is the CSS wildcard:

* {
    border:0;
}

However, only a few elements actually have borders by default (mainly tables, etc, but also img if it's inside an a), so you may prefer to list just those elements specificially:

body, table, tr, td, img {
    border:0;
}

It's more readable that way than *, and probably better practice too.

Hope that helps.

Spudley
It's just the body that I'm after. Can't remove the border even from that. Just added my code to the question.
Vitaly
+1  A: 

OK, it seems there is no way to remove the border from CSS when XHTML DOCTYPE is used in IE.

I ended up implementing GetHostInfo method of the IDocHostUIHandler interface of the WebBrowser control/component in my desktop app, as this example in Delphi illustrates: Frameless Web Browser

And here is another related question here on StackOverflow: Remove border on activex ie control

Vitaly