If you only need a simple label (text, but not HTML), then the Label widget is more appropriate, as it disallows the use of HTML, which can lead to potential security issues if not used properly.
public class HTMLExample implements EntryPoint { public void onModuleLoad() { // Create a Label and an HTML widget. Label lbl = new Label("This is just text. It will not be interpreted " + "as <html>."); HTML html = new HTML( "This is <b>HTML</b>. It will be interpreted as such if you specify " + "the <span style='font-family:fixed'>asHTML</span> flag.", true); // Add them to the root panel. VerticalPanel panel = new VerticalPanel(); panel.add(lbl); panel.add(html); RootPanel.get().add(panel); } }
HTML() | Creates an empty HTML widget. |
HTML(String) | Creates an HTML widget with the specified HTML contents. |
HTML(String, boolean) | Creates an HTML widget with the specified contents, optionally treating it as HTML, and optionally disabling word wrapping. |
getHTML() | Gets this object's contents as HTML. |
setHTML(String) | Sets this object's contents via HTML. |
false
to disable word wrapping