AngleSharp.Css 1.0.0-alpha-113

logo

AngleSharp.Css

CI GitHub Tag NuGet Count Issues Open Gitter Chat StackOverflow Questions CLA Assistant

AngleSharp.Css extends the core AngleSharp library with some more powerful CSS capabilities. This repository is the home of the source for the AngleSharp.Css NuGet package.

Basic Configuration

If you just want a configuration that works (as close as possible to real browsers) you should use the following code:

var config = Configuration.Default
    .WithCss(); // from AngleSharp.Css

This will register a parser for CSS related content. The CSS parsing options and more could be set with parameters of the WithCss method. Alternatively, all the (desired) parts may be registered individually as well. That mostly boils down to three elementary parts:

  • A CSS parser (implementing the ICssParser interface, e.g., CssParser)
  • A factory for creating CSS declarations (IDeclarationFactory)
  • The styling service that can handle CSS documents, see CssStylingService

For an interactive DOM (i.e., to handle style attribute changes in the HTML document) an observer needs to be registered as well.

Furthermore, for some CSSOM features (e.g., media queries) a render device is required.

var config = Configuration.Default
    .WithCss()
    .WithRenderDevice(new DefaultRenderDevice
    {
        DeviceHeight = 768,
        DeviceWidth = 1024,
    });

If no specific IRenderDevice (e.g., via creating an DefaultRenderDevice object) instance is created a default implementation will be set.

Going a bit further it is possible to Render the current document. This render tree information can then be used to retrieve or other information, e.g.,

var tree = document.DefaultView.Render();
var node = tree.Find(document.QuerySelector("div"));
await node.DownloadResources();

The previous snippet renders the current document. Afterwards it retrieves a particular render tree node, which is related to the first found div. Then all (CSS introduced) resources are downloaded for the node, if visible.

Advantages of AngleSharp.Css

The core library already contains the CSS selector parser and the most basic classes and interfaces for dealing with the CSSOM. AngleSharp.Css brings the following advantages and use cases to life:

  • Correct identification of edge cases
  • A live CSSOM model, i.e., callbacks and everything
  • Computing the styling of certain elements
  • Cascades of stylesheets
  • Validation (and property-based exposure) of CSS declarations
  • Responsive design considerations
  • Full access to the value with different converters

The main idea behind AngleSharp.Css is to expose the CSSOM as it would be in the browser (and potentially beyond, i.e., useful for being used by editors). Originally, most of the code found here was embedded in the AngleSharp.Core library, however, due to the overhead for HTML use cases it was decided to transfer the code into its own repository.

Features

  • Feature validators (e.g., for @supports)
  • Document functions (e.g., for domain)
  • Pseudo elements (e.g., ::before)
  • Declarations (e.g., display) incl. knowledge of their values
  • Dynamic DOM coupling (i.e., to react to style attribute changes)
  • CSS custom properties (also known as CSS variables) with extensibility
  • Media queries and all other commonly implemented rules
  • Calculated values (i.e., calc(20px + 50%))
  • Window-based declaration calculations, see window.GetComputedStyle

Participating

Participation in the project is highly welcome. For this project the same rules as for the AngleSharp core project may be applied.

If you have any question, concern, or spot an issue then please report it before opening a pull request. An initial discussion is appreciated regardless of the nature of the problem.

Live discussions can take place in our Gitter chat, which supports using GitHub accounts.

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.

For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

License

The MIT License (MIT)

Copyright (c) 2016 - 2024 AngleSharp

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Showing the top 20 packages that depend on AngleSharp.Css.

Packages Downloads
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
47
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
45
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
41
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
39
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
38
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
37
HtmlSanitizer
Cleans HTML from constructs that can be used for cross site scripting (XSS)
36
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
36
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
35
HtmlSanitizer
Cleans HTML from constructs that can be used for cross site scripting (XSS)
35
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS)
34
HtmlSanitizer
Cleans HTML from constructs that can be used for cross site scripting (XSS)
34

Any 0.0

Version Downloads Last updated
1.1.3-beta.330 14 09/13/2026
1.1.2 14 09/11/2026
1.1.2-beta.323 11 09/11/2026
1.1.2-beta.322 13 09/11/2026
1.1.2-beta.321 12 09/11/2026
1.1.1 16 09/10/2026
1.1.1-beta.317 17 09/10/2026
1.1.1-beta.316 16 09/10/2026
1.1.1-beta.311 16 09/10/2026
1.1.1-beta.310 13 09/09/2026
1.1.1-beta.309 16 09/09/2026
1.1.1-beta.308 19 09/07/2026
1.1.1-beta.307 15 09/07/2026
1.1.0 17 09/06/2026
1.1.0-beta.302 16 09/06/2026
1.1.0-beta.297 14 09/06/2026
1.1.0-beta.295 15 09/05/2026
1.1.0-beta.293 19 09/05/2026
1.1.0-beta.291 18 09/06/2026
1.1.0-beta.283 19 09/04/2026
1.1.0-beta.281 16 09/04/2026
1.1.0-beta.277 18 09/04/2026
1.1.0-beta.276 18 09/04/2026
1.1.0-beta.273 18 09/03/2026
1.0.2 17 08/23/2026
1.0.2-beta.272 22 09/02/2026
1.0.2-beta.271 19 09/02/2026
1.0.2-beta.265 19 08/20/2026
1.0.1 15 07/31/2026
1.0.1-beta.264 21 08/20/2026
1.0.1-beta.262 21 08/13/2026
1.0.1-beta.260 18 08/08/2026
1.0.1-beta.258 16 08/05/2026
1.0.1-beta.256 12 08/01/2026
1.0.1-beta.252 13 07/31/2026
1.0.1-beta.250 14 07/31/2026
1.0.1-beta.247 15 07/31/2026
1.0.1-beta.245 20 07/31/2026
1.0.0 16 07/27/2026
1.0.0-beta.244 14 07/29/2026
1.0.0-beta.243 18 07/28/2026
1.0.0-beta.239 13 07/25/2026
1.0.0-beta.237 15 07/25/2026
1.0.0-beta.231 23 07/25/2026
1.0.0-beta.228 18 07/22/2026
1.0.0-beta.226 14 07/22/2026
1.0.0-beta.224 21 07/20/2026
1.0.0-beta.222 21 07/20/2026
1.0.0-beta.216 42 05/14/2026
1.0.0-beta.213 38 04/01/2026
1.0.0-beta.211 44 03/29/2026
1.0.0-beta.209 39 03/29/2026
1.0.0-beta.204 42 03/29/2026
1.0.0-beta.202 41 03/29/2026
1.0.0-beta.199 44 03/29/2026
1.0.0-beta.197 42 03/29/2026
1.0.0-beta.195 33 03/29/2026
1.0.0-beta.189 38 03/29/2026
1.0.0-beta.186 43 03/29/2026
1.0.0-beta.184 41 03/29/2026
1.0.0-beta.178 50 03/28/2026
1.0.0-beta.176 27 03/29/2026
1.0.0-beta.167 55 01/17/2026
1.0.0-beta.164 43 12/10/2025
1.0.0-beta.159 47 12/10/2025
1.0.0-beta.157 44 12/13/2025
1.0.0-beta.154 53 12/09/2025
1.0.0-beta.151 47 12/13/2025
1.0.0-beta.149 52 12/12/2025
1.0.0-beta.147 33 12/09/2025
1.0.0-beta.144 43 12/13/2025
1.0.0-beta.139 48 12/10/2025
1.0.0-beta.137 52 12/13/2025
1.0.0-beta.130 46 01/01/2026
1.0.0-beta.127 34 12/09/2025
1.0.0-beta.122 50 12/22/2025
1.0.0-alpha-99 29 12/10/2025
1.0.0-alpha-98 51 12/20/2025
1.0.0-alpha-97 42 12/12/2025
1.0.0-alpha-117 54 12/13/2025
1.0.0-alpha-113 39 12/09/2025
1.0.0-alpha-111 52 12/15/2025
1.0.0-alpha-109 51 01/09/2026
1.0.0-alpha-108 32 12/10/2025
1.0.0-alpha-107 42 12/09/2025
1.0.0-alpha-106 42 12/15/2025
1.0.0-alpha-104 49 12/16/2025
1.0.0-alpha-103 32 12/10/2025
1.0.0-alpha-102 44 12/18/2025
1.0.0-alpha-101 44 12/16/2025
1.0.0-alpha-100 48 12/15/2025
0.18.0 13 07/25/2026
0.18.0-beta.233 15 07/25/2026
0.17.0 55 12/15/2025
0.17.0-alpha-87 43 12/09/2025
0.17.0-alpha-86 51 12/10/2025
0.17.0-alpha-80 42 12/13/2025
0.17.0-alpha-78 48 12/21/2025
0.17.0-alpha-77 33 12/09/2025
0.17.0-alpha-76 43 12/24/2025
0.17.0-alpha-75 51 12/09/2025
0.16.4 34 12/11/2025
0.16.4-alpha-72 45 12/14/2025
0.16.4-alpha-68 33 01/01/2026
0.16.3 43 12/09/2025
0.16.3-alpha-65 37 12/09/2025
0.16.2 43 01/02/2026
0.16.2-alpha-62 42 12/09/2025
0.16.2-alpha-61 35 12/24/2025
0.16.2-alpha-60 39 01/01/2026
0.16.2-alpha-42 37 12/09/2025
0.16.2-alpha-35 29 12/14/2025
0.16.2-alpha-30 30 01/17/2026
0.16.2-alpha-29 43 12/11/2025
0.16.2-alpha-28 30 01/01/2026
0.16.1 40 12/12/2025
0.16.1-alpha-27 44 12/09/2025
0.16.1-alpha-24 43 12/21/2025
0.16.0 36 01/09/2026
0.16.0-alpha-23 44 12/12/2025
0.16.0-alpha-19 44 12/11/2025
0.15.1 41 01/17/2026
0.15.1-alpha-13 45 01/01/2026
0.15.1-alpha-11 37 12/15/2025
0.15.0 34 12/19/2025
0.15.0-alpha-7 43 12/15/2025
0.14.3-alpha-5 28 12/12/2025
0.14.3-alpha-4 31 12/20/2025
0.14.3-alpha-166 44 12/15/2025
0.14.3-alpha-165 44 12/10/2025
0.14.2 40 12/24/2025
0.14.2-alpha-163 37 12/09/2025
0.14.2-alpha-162 42 12/20/2025
0.14.1 41 01/01/2026
0.14.1-alpha-161 46 12/15/2025
0.14.0 46 12/13/2025
0.14.0-alpha-160 47 12/14/2025
0.14.0-alpha-154 43 01/09/2026
0.14.0-alpha-152 45 01/01/2026
0.14.0-alpha-149 51 01/01/2026
0.14.0-alpha-147 37 12/14/2025
0.14.0-alpha-145 52 12/22/2025
0.14.0-alpha-143 38 12/09/2025
0.14.0-alpha-139 42 12/15/2025
0.14.0-alpha-138 45 01/09/2026
0.13.0 41 12/24/2025
0.13.0-alpha-135 44 01/09/2026
0.13.0-alpha-131 50 12/10/2025
0.13.0-alpha-123 38 12/09/2025
0.13.0-alpha-121 37 01/23/2026
0.13.0-alpha-119 44 12/22/2025
0.13.0-alpha-117 35 01/01/2026
0.13.0-alpha-116 41 12/19/2025
0.13.0-alpha-115 42 12/22/2025
0.13.0-alpha-114 41 12/14/2025
0.13.0-alpha-113 47 12/09/2025
0.12.1 37 12/30/2025
0.12.0 44 12/09/2025
0.10.0 41 12/09/2025