1

Is there a way to specify a user agent stylesheet in JavaFX Webview? (meaning the default stylesheet which the webpages themselves can override via .css files if they refer to it in the HTML <head> section)

see What is user agent stylesheet

and CSS 2.1:

Style sheets may have three different origins: author, user, and user agent.

  • Author. The author specifies style sheets for a source document according to the conventions of the document language. For instance, in HTML, style sheets may be included in the document or linked externally.
  • User: The user may be able to specify style information for a particular document. For example, the user may specify a file that contains a style sheet or the user agent may provide an interface that generates a user style sheet (or behaves as if it did).
  • User agent: Conforming user agents must apply a default style sheet (or behave as if they did). A user agent's default style sheet should present the elements of the document language in ways that satisfy general presentation expectations for the document language (e.g., for visual browsers, the EM element in HTML is presented using an italic font). See A sample style sheet for HTML for a recommended default style sheet for HTML documents. Note that the user may modify system settings (e.g., system colors) that affect the default style sheet. However, some user agent implementations make it impossible to change the values in the default style sheet.
Community
  • 1
  • 1
Jason S
  • 184,598
  • 164
  • 608
  • 970

1 Answers1

2

webView.getEngine().setUserStylesheetLocation(...);

James_D
  • 201,275
  • 16
  • 291
  • 322
  • What are the semantics of this? Unfortunately the API doesn't seem to state this information in the javadocs, and I am not sure whether "user stylesheets" and "user agent stylesheets" are the same thing. – Jason S Jul 25 '16 at 22:23
  • Not entirely sure, but I find it hard to imagine it meaning anything other than user agent style sheet, given that it is a property of the engine. – James_D Jul 25 '16 at 22:27