smail/style

This module provides all the CSS style properties that have been officially tested for email client compatibility. Using these functions is strongly recommended over raw attribute.style calls, as they handle unit conversions (such as rem to px) and ensure the properties work correctly across email clients.

For any property not covered here, attribute.style remains available as an escape hatch.

Values

pub fn background_color(value: String) -> attribute.Attribute

Sets the background colour of the element.

pub fn border(value: String) -> attribute.Attribute

Sets the border on all four sides of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn border_bottom(value: String) -> attribute.Attribute

Sets the border on the bottom side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn border_collapse(value: String) -> attribute.Attribute

Sets how table borders are rendered. Common values are "collapse" and "separate".

pub fn border_left(value: String) -> attribute.Attribute

Sets the border on the left side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn border_radius(value: String) -> attribute.Attribute

Sets the rounding of the element’s corners. Any rem values are automatically converted to px for maximum email client compatibility.

Note: border-radius is not supported in Outlook.

pub fn border_right(value: String) -> attribute.Attribute

Sets the border on the right side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn border_top(value: String) -> attribute.Attribute

Sets the border on the top side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn color(value: String) -> attribute.Attribute

Sets the foreground color of the element’s text content.

Note: unlike standard email clients where color inheritance is unreliable, this library ensures the color cascades correctly to child elements.

pub fn direction(value: String) -> attribute.Attribute

Sets the text direction for the element’s content. Common values are "ltr" (left-to-right) and "rtl" (right-to-left).

pub fn display(value: String) -> attribute.Attribute

Sets how the element is displayed. Common values are "block", "inline", "inline-block", and "none".

pub fn font_family(value: String) -> attribute.Attribute

Sets the font family for the element’s text. Multiple font names can be provided as a comma-separated fallback list, e.g. "Arial, sans-serif".

pub fn font_size(value: String) -> attribute.Attribute

Sets the size of the font. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn font_style(value: String) -> attribute.Attribute

Sets the style of the font. Common values are "normal" and "italic".

pub fn font_weight(value: String) -> attribute.Attribute

Sets the weight (boldness) of the font. Common values are "normal", "bold", or a numeric value such as "700".

pub fn height(value: String) -> attribute.Attribute

Sets the height of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn letter_spacing(value: String) -> attribute.Attribute

Sets additional spacing between individual characters. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn line_height(value: String) -> attribute.Attribute

Sets the height of a line of text. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn margin(value: String) -> attribute.Attribute

Sets the margin on all four sides of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn margin_bottom(value: String) -> attribute.Attribute

Sets the margin on the bottom side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn margin_left(value: String) -> attribute.Attribute

Sets the margin on the left side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn margin_right(value: String) -> attribute.Attribute

Sets the margin on the right side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn margin_top(value: String) -> attribute.Attribute

Sets the margin on the top side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn max_width(value: String) -> attribute.Attribute

Sets the maximum width of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn min_width(value: String) -> attribute.Attribute

Sets the minimum width of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn overflow(value: String) -> attribute.Attribute

Sets how content that overflows the element’s box is handled. Common values are "visible", "hidden", "scroll", and "auto".

pub fn padding(value: String) -> attribute.Attribute

Sets the padding on all four sides of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn padding_bottom(value: String) -> attribute.Attribute

Sets the padding on the bottom side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn padding_left(value: String) -> attribute.Attribute

Sets the padding on the left side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn padding_right(value: String) -> attribute.Attribute

Sets the padding on the right side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn padding_top(value: String) -> attribute.Attribute

Sets the padding on the top side of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn rem_to_px(value: String) -> String

Converts rem values to px in a space-separated string of CSS values. Any token ending in rem is multiplied by 16 to produce its pixel equivalent. Tokens that are not rem values are left unchanged.

pub fn text_align(value: String) -> attribute.Attribute

Sets the horizontal alignment of inline content. Accepted values are "left", "right", "center", and "justify".

pub fn text_decoration(value: String) -> attribute.Attribute

Sets decorative lines on text. Common values are "none", "underline", "overline", and "line-through".

pub fn text_transform(value: String) -> attribute.Attribute

Controls the capitalisation of text. Common values are "none", "uppercase", "lowercase", and "capitalize".

pub fn vertical_align(value: String) -> attribute.Attribute

Sets the vertical alignment of the element relative to its line box or table cell. Common values are "top", "middle", and "bottom".

pub fn white_space(value: String) -> attribute.Attribute

Sets how white space inside an element is handled. Common values are "normal", "nowrap", and "pre".

pub fn width(value: String) -> attribute.Attribute

Sets the width of the element. Any rem values are automatically converted to px for maximum email client compatibility.

pub fn word_break(value: String) -> attribute.Attribute

Controls how line breaks occur within words when they overflow their container. Common values are "normal", "break-all", and "keep-all".

pub fn word_wrap(value: String) -> attribute.Attribute

Controls whether the browser may break lines within words to prevent overflow. Common values are "normal" and "break-word".

Search Document