CSS Extensions – CSS Vendor Prefixes – Aspose.HTML for .NET
CSS Vendor Prefixes
CSS vendor prefixes, sometimes called CSS browser prefixes, are used in CSS property names to implement experimental or pre-release CSS features that are not yet standardized or may have limited support in certain browsers. In other words, the reason for the existence of prefixes was to specify browser-specific features.
Historically, browser vendors use the prefixes for nonstandard CSS features. Following is the list of the major browsers prefixes:
- -webkit- (Chrome, Safari, newer versions of Opera, almost all iOS browsers (including Firefox for iOS); basically, any WebKit based browser)
- -moz- (Mozilla-based browsers such as Firefox)
- -o- (Old, pre-WebKit, versions of Opera)
- -ms- (Internet Explorer and Microsoft Edge)
According to the CSS specification, CSS vendor-specific extensions must start with a dash or underscore and have the following format:
['-' or '_'] + [vendor identifier] + ['-'] + [name]
For example, the -webkit-text-stroke
CSS property is a vendor-prefixed property used to specify the width and color of strokes for text characters in WebKit-based browsers, and -moz-border-radius
is a vendor-prefixed property that allows you to round the corners of elements to create a visually appealing and modern design in Mozilla-based browsers, such as Firefox.
CSS Extensions – Aspose.HTML
The prefix that is used by Aspose.HTML library looks like -aspose- and gives you some experimental features. Following is a list of CSS functions that can be enabled by using -aspose- prefix:
Function Name | Description |
---|---|
currentPageNumber | This function returns the number of the current rendering page. |
totalPagesNumber | This function returns the number of the total pages in the document. |
Aspose CSS Extension – C# Example
The next code snippet demonstrates how to use CSS extensions to create custom marks on document margins:
1// Initialize a configuration object and set up page-margins for a document
2using (Configuration configuration = new Configuration())
3{
4 // Get the User Agent service
5 var userAgent = configuration.GetService<IUserAgentService>();
6
7 // Set the style of custom margins and create marks on it
8 userAgent.UserStyleSheet = @"@page
9 {
10 /* Page margins should be not empty in order to write content inside the margin-boxes */
11 margin-top: 1cm;
12 margin-left: 2cm;
13 margin-right: 2cm;
14 margin-bottom: 2cm;
15 /* Page counter located at the bottom of the page */
16 @bottom-right
17 {
18 -aspose-content: ""Page "" currentPageNumber() "" of "" totalPagesNumber();
19 color: green;
20 }
21
22 /* Page title located at the top-center box */
23 @top-center
24 {
25 -aspose-content: ""Hello, World Document Title!!!"";
26 vertical-align: bottom;
27 color: blue;
28 }
29 }";
30
31 // Initialize an HTML document
32 using HTMLDocument document = new HTMLDocument("<div>Hello, World!!!</div>", ".", configuration);
33
34 // Initialize an output device
35 using (PdfDevice device = new PdfDevice(Path.Combine(OutputDir, "output.pdf")))
36 {
37 // Send the document to the output device
38 document.RenderTo(device);
39 }
40}
Aspose.HTML offers HTML Web Applications that are an online collection of free converters, mergers, SEO tools, HTML code generators, URL tools, and more. The applications work on any operating system with a web browser and do not require any additional software installation. Easily convert, merge, encode, generate HTML code, extract data from the web, or analyze web pages in terms of SEO wherever you are. Use our collection of HTML Web Applications to perform your daily matters and make your workflow seamless!