[Solved] How do I style HTML correctly using an external CSS file? [closed]


Based on the JavaDoc – jEditorPane supports the bleeding edge HTML 3.2 and CSS1 so the short answer is, you really don’t want to try rendering modern web pages with it.

However, you may be able to do this:

import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;

HTMLEditorKit kit = new HTMLEditorKit();
jEditorPane.setEditorKit(kit);

URL url = new URL(location of your stylesheet);
StyleSheet styleSheet = new StyleSheet();
styleSheet.importStyleSheet(url)
kit.setStyleSheet(styleSheet);

solved How do I style HTML correctly using an external CSS file? [closed]