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:

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 NameDescription
currentPageNumberThis function returns the number of the current rendering page.
totalPagesNumberThis 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// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-.NET
 2//  Initialize configuration object and set up the page-margins for the document
 3using (Configuration configuration = new Configuration())
 4{
 5    // Get the User Agent service
 6    var userAgent = configuration.GetService<Aspose.Html.Services.IUserAgentService>();
 7
 8    // Set the style of custom margins and create marks on it
 9    userAgent.UserStyleSheet = @"@page 
10                                {
11                                    /* Page margins should be not empty in order to write content inside the margin-boxes */
12                                    margin-top: 1cm;
13                                    margin-left: 2cm;
14                                    margin-right: 2cm;
15                                    margin-bottom: 2cm;
16                                    /* Page counter located at the bottom of the page */
17                                    @bottom-right
18                                    {
19                                        -aspose-content: ""Page "" currentPageNumber() "" of "" totalPagesNumber();
20                                        color: green;
21                                    }
22
23                                    /* Page title located at the top-center box */
24                                    @top-center
25                                    {
26                                        -aspose-content: ""Hello World Document Title!!!"";
27                                        vertical-align: bottom;
28                                        color: blue;
29                                    }    
30                                }";
31
32    //  Initialize an HTML document 
33    using (HTMLDocument document = new HTMLDocument("<div>Hello World!!!</div>", ".", configuration))
34    {
35        //  Initialize an output device
36        using (Aspose.Html.Rendering.Xps.XpsDevice device = new Aspose.Html.Rendering.Xps.XpsDevice("output.xps"))
37        {
38            // Send the document to the output device
39            document.RenderTo(device);
40        }
41    }
42}

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!

Text “Banner HTML Web Applications”

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.