Forum Archive

ui.webview.load_html()

Cook92

I'm just fiddling with something....would appreciate some input.
If I have some HTML code with CSS and put it into ui.webview.load_html() it seems it cannot handle all CSS parameters.
I don't know the scope of CSS that it can handle, but I found that table properties don't seem to work.

Simple Example to use as html to pass to load_html():

<html><style>table {border-width:1px}</style><table><tr><td>This table should have a border</td></tr></table></html>

It won't have a border. At least from what I've tried!

However, the below method will provide a border, however this is poor way to go about things in html:

<html><table border = 1><tr><td>This table should have a border</td></tr></table></html>

Is there something I should do to get that working....?

Also note: ui.Webview itself handles CSS properly if I load an actual webpage (load_url).

Cook92

sorry- it seems I can't delete this.... I answered my own question:
(hrm...seems I need to read up on my css!)

{border: 1px solid black;}

dgelessus

My HTML is a little rusty, but I've never seen CSS embedded using a <style> tag before. Have you tried setting the CSS property on the <table> tag directly, or using a <link/> tag in the <head> to use an external CSS file?

By the way, it seems that you have no <head> or <body> tags. The <style> tag might need to be in the <head>.

Cook92

You're right about all of those things.

CSS can be used in three ways - externally linked, internal , and in the tag

For what I'm doing right now- the internal style sheet is sufficient and arguably easier(?). I'm scraping some html and then showing it in webview.
Could do re.sub but I'm just adding a bunch of stringy html code and that's easy enough!