To the best of my knowledge, the syntax and values seem correct. Please see the code snippet below.
* {
overflow: hidden;
background-color: rgba(30, 30, 30, .9);
color: rgb(242, 238, 229);
font-size: 18px;
font-family: Segoe UI,...;
}
The only property that appears to be ignored is background-color
. Using !important
did not make a difference.
Here is the template HTML:
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' type='text/css' href='data:text/css;charset=UTF-8,{0}'>
</head>
<body>
{1}
</body>
</html>
(The {0,1}
placeholders are used for formatting in a C# WPF application and then passing the HTML code to an embedded WebBrowser)
The 0 corresponds to URI encoded CSS, which works as intended.
Below is the segment of code from my WPF application:
TextRange rng = new TextRange(
TextEntry.Document.ContentStart,
TextEntry.Document.ContentEnd);
string cssString = ":not(h1,h2,h3,h4,h5,h6) { font-size: 11px; } * { overflow: hidden; background-color: rgba(30, 30, 30, .9); color: rgb(242, 238, 229); font-family: Segoe UI...; }";
string htContent = string.Format("<!DOCTYPE html><html><head><link rel='stylesheet' type='text/css'"
+ "href='data:text/css;charset=UTF-8,{0}'></head><body>{1}</body></html>",
Uri.EscapeUriString(cssString),
Markdig.Markdown.ToHtml(rng.Text));
Unfortunately, no matter how specific I make the background-color
property, it remains unresponsive.
For reference, here is the XAML code for the WebBrowser in my application:
<WebBrowser x:Name="Markdown" HorizontalAlignment="Left" Height="406" Margin="16,36,-9,0" VerticalAlignment="Top" Width="800" Grid.RowSpan="2"/>
All other similar issues I found were due to an element overriding the style, but since this HTML and CSS are fairly standard, I couldn't pinpoint any such conflicts.