views:

142

answers:

2

I'm using a System.Windows.Forms.WebBrowser control next to textboxes with the left margins of each control aligned on the same X axis. The appearance however is "ugly" because the WebBrowser control inserts a margin/padding around the content of the control. Therefore the text in the WebBrowser control is several pixels to the right of the text in the textboxes above and below the WebBrowser control.

How do you fix this? The Margin setting does not appear to work.

+4  A: 

What content are you putting inside of the web browser control? If it is HTML that has margins or padding defined (or using the defaults) you could try defining the HTML with no margins or padding around the body and see if that fixes your problem.

daddyman
Agree, if there's no style defined for the page being browsed, there's going to be margins and padding by default.
CAbbott
Thanks. I had tried that but it doesn't help when you try the change the wrong thing :(The fix is this:<html><body style="padding: 0; margin: 0;">your content</body></html>
Tim Murphy
+1  A: 

I came across this same problem, and an additional thing to watch out for is if your app is going to be installed on computers using IE6. IE6 by default seems to add a border to the left and top sides, which will have the same effect of make the text in your WebBrowser not exactly aligned as you want and with a couple of additional 'ugly' borders as a bonus. html { border:0px } body {margin: 0px; padding:0px;} in the CSS fixed it all for me.

miket2e