question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Loading CSS

See original GitHub issue

Hey 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FlorianRapplcommented, Mar 27, 2016

Included, see #306.

1reaction
FlorianRapplcommented, Mar 27, 2016

AngleSharp is used like the browser. The Style property only contains information about the inline style, i.e., an ICssStyleDeclaration obtained by parsing the style attribute of the corresponding element.

What you want to go for is GetComputedStyle available on the IWindow, but be careful - this feature is not completely ready yet and only performs trivial computations to obtain an ICssStyleDeclaration of the given element using all active stylesheets (linked and inline) / style information.

Maybe I’ll add a handy helper that is used like

var style = element.ComputeCurrentStyle();

instead of the current, explicit version

var window = element.Owner.DefaultView;
var style = window.GetComputedStyle(element);
Read more comments on GitHub >

github_iconTop Results From Across the Web

problem with loading css and javascript after get request
The way a browser works is that it load an HTML page, parses it and then finds other resources such as css files,...
Read more >
Loading in CSS files - question Front End Developer Exam
Today I tried my Front End Developers exam. One of the questions stroke me as odd: "Seeing the picture below, how many CSS...
Read more >
Loading css files conditionally useful?
One of the cases I use for conditional css loading is that if I have a page that have very different style. or...
Read more >
CSS Interview Questions and Answers [Top 75+]
Cover the top CSS interview questions asked by popular companies. Prepare for the frequently ask'd CSS questions from beginners to advanced ...
Read more >
Question about loading javascript and css dynamically
I'd like to be able to load a javascript and/or css file as a reaction to a user choice and then run the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found