Class Style


@Marshalled(typeName="style") public class Style extends HtmlElementRawText<Style>
DTO for an HTML <style> element.

The style element allows authors to embed CSS style information in their documents. It contains CSS rules that apply to the document. The style element is typically placed in the head section of the document, but can also be used inline. The CSS contained within the style element is processed by the browser and applied to the document.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Basic CSS styles Style basic = style() .text("body { font-family: Arial, sans-serif; }"); // CSS with media query Style responsive = style() .media("screen and (max-width: 600px)") .text("body { font-size: 14px; }"); // Multiple CSS rules Style multiple = style() .text( "h1 { color: blue; }", "p { margin: 10px; }", ".highlight { background-color: yellow; }" ); // CSS with type specification Style typed = style() .type("text/css") .text(".button { padding: 10px; background: #007bff; }"); // Print-specific styles Style print = style() .media("print") .text("body { color: black; background: white; }");

The following convenience methods are provided for constructing instances of this bean:

See Also:
  • Constructor Details

  • Method Details

    • media

      public Style media(String value)
      media attribute.

      Specifies the media types for which the stylesheet applies. This allows you to target specific devices or media types.

      Common values:

      • "all" - All media types (default)
      • "screen" - Computer screens
      • "print" - Printers and print preview
      • "handheld" - Handheld devices
      • "projection" - Projectors
      • "tv" - Television
      Parameters:
      value - The media types for which the stylesheet applies. Can be null to unset the attribute.
      Returns:
      This object.
    • type

      public Style type(String value)
      type attribute.

      Type of embedded resource.

      Parameters:
      value - The new value for this attribute. Can be null to unset the attribute.
      Returns:
      This object.