[Question] Loading CSS
See original GitHub issueHey there, I’m happy that I got to know this project - convenient package ! Now, to the issue: I’m trying to load really simple HTML with some styling defined in the HEAD - right in the same document, not in external file using link. And the problem is that the rules from the STYLE tags are not reflected on the elements itself, but when the style property of the elements itself is used, the style properties from the style property is reflected on the Style property of the element.
How can I enable loading this info into the elements ? Is there such functionality ? Or should I get the rules and apply them manually by setting the style properties on these elements (which is an option, but odd) ?
I’m initializing the AS like below
var parser = new HtmlParser(Configuration.Default.WithCss());
var DOM = parser.Parse(source);
Thanks for response.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Included, see #306.
AngleSharp is used like the browser. The
Style
property only contains information about the inline style, i.e., anICssStyleDeclaration
obtained by parsing thestyle
attribute of the corresponding element.What you want to go for is
GetComputedStyle
available on theIWindow
, but be careful - this feature is not completely ready yet and only performs trivial computations to obtain anICssStyleDeclaration
of the given element using all active stylesheets (linked and inline) / style information.Maybe I’ll add a handy helper that is used like
instead of the current, explicit version