Styles
Control element appearance with inline CSS
imgrender currently supports only inline CSS to control styles:
imgrender does not yet support using Style Sheets to manage styles
Inline CSS
Set inline styles with the style attribute. Property names use standard CSS hyphenated form (such as font-size). Use : between a property and its value, and separate multiple properties with ;.
<div style="color: red; font-size: 20px">Hello imgrender</div>Supported styles
The table below lists supported style properties, values, and limitations.
| Property | Expanded properties | Supported values | Limitations |
|---|---|---|---|
display | none, flex, inline-flex, grid, inline-grid, block, inline-block, inline, flow-root, list-item, table, table-row, table-cell, table-header-group, table-row-group, table-footer-group, table-caption. Tables support fixed column widths, captions, and row-group ordering | Column widths and caption spacing may differ from browsers | |
position | static, relative, absolute, fixed. static does not apply positioning offsets. fixed is positioned relative to the canvas | — | |
direction | ltr, rtl. Inheritance, child overrides, and start-edge text alignment are supported | — | |
float | left, right, none | — | |
clear | left, both | none and right may still place the element below a taller float | |
z-index | Supported | — | |
width | Lengths, auto, fit-content, stretch. block supports percentages | A percentage width on inline-block may paint the background too narrow. Widths from min-content and max-content may not match the content size. Use an explicit length | |
height | Lengths, percentages, auto, min-content, max-content, fit-content, stretch | — | |
max-width | Lengths, percentages, auto, none. Neither auto nor none sets an upper limit | Does not support min-content, max-content, fit-content, or stretch | |
max-height | Lengths, percentages, auto, none. Neither auto nor none sets an upper limit | Does not support min-content, max-content, fit-content, or stretch | |
min-width | Lengths, percentages, auto | Does not support min-content, max-content, fit-content, or stretch | |
min-height | Lengths, percentages, auto | Does not support min-content, max-content, fit-content, or stretch | |
aspect-ratio | A ratio used to compute an automatic width or height | When both width and height are specified, the ratio may override the explicit height | |
contain | none, style, layout, paint, and non-repeating combinations. content is equivalent to layout style paint. layout establishes a containing block for absolute positioning. paint clips overflow | Does not support size, inline-size, or strict | |
animation | animation-name | Supported | — |
animation-duration | Supported | — | |
animation-delay | Supported | — | |
animation-timing-function | linear, ease, ease-in, ease-out, ease-in-out, step-start, step-end, steps(), cubic-bezier() | — | |
animation-iteration-count | Supported | — | |
animation-direction | Supported | — | |
animation-fill-mode | Supported | — | |
animation-play-state | Supported | — | |
padding | padding-top, padding-right, padding-bottom, padding-left, padding-inline, padding-inline-start, padding-inline-end, padding-block | Supported | — |
margin | margin-top, margin-right, margin-bottom, margin-left, margin-inline, margin-inline-start, margin-inline-end, margin-block | Supported | — |
inset | top, right, bottom, left, inset-inline, inset-block | Supported | Under RTL, inset-inline does not swap the left and right edges. Use left and right |
border | border-width (border-top-width, border-right-width, border-bottom-width, border-left-width, border-inline-width, border-block-width) | Lengths (including 0) | A visible border may make the outer box size differ from what you expect. Set box-sizing explicitly. Under RTL, border-inline-width does not swap the left and right edges. Use border-left-width and border-right-width. When an empty element is not painted, remove the indented white space inside it |
border-style | none, hidden, solid, dashed, dotted, double, groove, ridge, inset, outset. none does not paint a border | — | |
border-color | Supported | — | |
border-radius | border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius | Supported | — |
border-top, border-right, border-bottom, border-left | A combination of width, style, and color for a single side | Set box-sizing explicitly to determine the outer box size | |
border-top-style, border-right-style, border-bottom-style, border-left-style | none, hidden, solid, dashed, dotted, double, groove, ridge, inset, outset | — | |
border-top-color, border-right-color, border-bottom-color, border-left-color | Color values (including transparent) | — | |
corner-shape | corner-top-left-shape, corner-top-right-shape, corner-bottom-left-shape, corner-bottom-right-shape | round, squircle, bevel, scoop, notch, square, superellipse(2), superellipse(0) | Must be used with border-radius |
outline | outline-width | Supported | — |
outline-style | none, hidden, solid, dashed, dotted, double, groove, ridge, inset, outset. Neither hidden nor none paints an outline | — | |
outline-color | Supported | — | |
outline-offset | Supported | — | |
flex | flex-basis | Lengths, percentages, content, auto, min-content, max-content, fit-content, stretch | — |
flex-grow | Supported | — | |
flex-shrink | Supported | — | |
order | Supported | — | |
| Flexbox | flex-direction | row, row-reverse, column, column-reverse | — |
flex-flow | Supported | — | |
flex-line-count | 1, 2, 3 | Use with flex-wrap: balance to set the minimum number of lines | |
-webkit-box-orient | horizontal, vertical. These correspond to flex-direction: row and column respectively | — | |
-webkit-box-pack | start, end, center, justify. These correspond to the justify-content values flex-start, flex-end, center, and space-between respectively | — | |
-webkit-box-align | start, end, center, baseline, stretch. These correspond to the align-items values flex-start, flex-end, center, baseline, and stretch respectively | — | |
justify-content | normal, stretch, start, end, flex-start, flex-end, center, space-between, space-around, space-evenly. safe and unsafe are supported | safe does not support normal, stretch, or space-distribution values. On overflow, safe falls back to the start side, and unsafe keeps the specified alignment | |
justify-self | Grid layout: normal, baseline, stretch, start, end, flex-start, flex-end, self-start, self-end, center. safe and unsafe are supported | safe does not support normal, baseline, or stretch. On overflow, safe falls back to the start side, and unsafe keeps the specified alignment. auto is not supported | |
align-content | normal, stretch, start, end, flex-start, flex-end, center, space-between, space-around, space-evenly. safe and unsafe are supported | safe does not support normal, stretch, or space-distribution values. On overflow, safe falls back to the start side, and unsafe keeps the specified alignment | |
place-content | center center | — | |
justify-items | Grid layout: normal, baseline, stretch, start, end, flex-start, flex-end, self-start, self-end, center. safe and unsafe are supported | safe does not support normal, baseline, or stretch. On overflow, safe falls back to the start side, and unsafe keeps the specified alignment | |
align-items | Grid layout: normal, baseline, stretch, start, end, flex-start, flex-end, self-start, self-end, center. safe and unsafe are supported | safe does not support normal, baseline, or stretch. On overflow, safe falls back to the start side, and unsafe keeps the specified alignment | |
place-items | Grid layout: center | — | |
align-self | Grid layout: normal, baseline, stretch, start, end, flex-start, flex-end, self-start, self-end, center. safe and unsafe are supported | safe does not support normal, baseline, or stretch. On overflow, safe falls back to the start side, and unsafe keeps the specified alignment. auto is not supported | |
place-self | Grid layout: end | — | |
flex-wrap | nowrap, wrap, wrap-reverse, balance, wrap balance, balance wrap, wrap-reverse balance, balance wrap-reverse. balance can be combined with flex-line-count. Reversed combinations swap the direction in which lines are arranged | — | |
gap (column-gap, row-gap) | Supported | — | |
object-fit | contain, cover, fill, none, scale-down | — | |
object-position | center, left top, right bottom, 50% 50% | — | |
caption-side | top, bottom. The caption is placed above or below the table | Spacing may differ from browsers | |
border-collapse | separate, collapse. Adjacent borders are shown separately or merged, respectively | — | |
border-spacing | One length or two lengths. Two values set the horizontal and vertical spacing respectively | — | |
table-layout | auto, fixed | Column widths and caption spacing may differ from browsers | |
overflow | overflow-x, overflow-y | visible, clip, hidden. clip and visible can clip on independent axes | A per-axis combination of hidden and visible may clip both axes |
background | Color values | Combining color, image, position, size, and repeat may show only the background color. Use the longhand properties below separately | |
| Background longhand properties | background-image | linear-gradient(), radial-gradient(), conic-gradient(), repeating-linear-gradient(), repeating-radial-gradient(), repeating-conic-gradient(), url() | — |
background-position | left top, center, right bottom | — | |
background-origin | border-box, padding-box, content-box. Controls the positioning origin of the background image | — | |
background-size | contain, cover, auto. Explicit width and height are supported, such as 100px 50px | — | |
background-repeat | no-repeat, repeat, repeat-x, repeat-y | — | |
background-color | Supported | — | |
background-clip | content-box, padding-box, border-box, text. text, together with a transparent text fill, shows the background inside the glyphs | The clipping region is affected by padding, borders, and the box model. Set box-sizing explicitly. When an empty element is not painted, remove the indented white space inside it | |
background-blend-mode | normal, multiply, screen | — | |
box-shadow | Supported | — | |
| Clip | clip-path | circle(), inset(), polygon(), none | Does not support ellipse(50px 30px at center) |
clip-rule | evenodd, nonzero. Applies to polygon() in HTML. The two values can leave a hole or fill the center, respectively. You can also use polygon(evenodd, ...) to set the shape's own rule | — | |
mask | linear-gradient(to right, transparent, #000) | The shorthand that combines image, position, size, and repeat has no effect. Use the longhand properties below. When an empty element is not painted, remove the indented white space inside it | |
| Mask longhand properties | mask-image | url(), linear-gradient(), none. Use with mask-position, mask-size, and mask-repeat to set an image mask | When an empty element is not painted, remove the indented white space inside it |
mask-size | Explicit width and height are supported, such as 100px 50px | — | |
mask-position | left top, center, right bottom | — | |
mask-repeat | no-repeat, repeat, repeat-x, repeat-y | — | |
transform | translate(), translateX(), translateY(), rotate(), scale(), scaleX(), scaleY(), matrix(), skewX(), skewY(), none. Function combinations are supported, and order affects the result | Only 2D transforms are supported. When an empty element is not painted, remove the indented white space inside it | |
| Individual 2D transform properties | translate | 2D translation, such as 40px 20px | translate-x and translate-y are not supported. Use translateX() and translateY() on transform. When an empty element is not painted, remove the indented white space inside it |
rotate | 2D rotation is supported, such as 90deg | When an empty element is not painted, remove the indented white space inside it | |
scale | 2D scaling, such as 1.5 0.5 | scale-x and scale-y are not supported. Use scaleX() and scaleY() on transform. When an empty element is not painted, remove the indented white space inside it | |
transform-origin | center, 0 0, 100% 100% | — | |
offset | path("M 0 0 L 200 0") 50% 0deg, path("M 0 0 L 200 0") 50px auto | — | |
offset-path | Straight-line path(), and circle(), ellipse(), and polygon() with an explicit center | Positions for ray(), inset(), border-box, and content-box may not match expectations. url() is not supported | |
offset-distance | Lengths and percentages. Percentages are relative to the path length | — | |
offset-rotate | auto, reverse, 0deg, 90deg, auto 30deg | — | |
offset-anchor | auto, 0 0, 100% 100% | Does not support center | |
offset-position | normal, auto, 0 0, 50% 50% | — | |
| Grid | grid-auto-columns | Lengths are supported, such as 80px | — |
grid-auto-rows | Lengths are supported, such as 30px | — | |
grid-auto-flow | row, column, row dense | — | |
grid-column (grid-column-start, grid-column-end) | Numeric grid-line start and end are supported, such as 2 / 4. Spans are supported, such as 2 / span 2 | — | |
grid-row (grid-row-start, grid-row-end) | Numeric grid-line start and end are supported, such as 1 / 3 | — | |
grid-area (grid-row-start, grid-column-start, grid-row-end, grid-column-end) | Numeric grid-line form is supported, such as 1 / 2 / 3 / 4 | Named areas are not supported | |
grid-template-columns | Combinations of lengths, fr, repeat(), and minmax() | — | |
grid-template-rows | Length lists and repeat() | — | |
list-style | square inside, decimal outside | A shorthand that includes an image may have no effect. Use list-style-image | |
list-style-type | none, decimal, decimal-leading-zero, lower-alpha, lower-latin, upper-alpha, upper-latin, lower-roman, upper-roman, and the string "X" | disc, circle, and square differ in marker size or first-line occupancy | |
list-style-position | inside, outside. These respectively include the marker in the first line's occupied space or place it outside the content area | — | |
list-style-image | url() image markers and none. none removes the image and restores the type marker | — | |
| Typography | text-overflow | ellipsis, clip | Custom strings are not supported and are treated as clip |
text-transform | none, uppercase, lowercase, capitalize | — | |
font-style | Supported | — | |
color | Supported | — | |
text-shadow | Supported | — | |
font-size | Supported | — | |
font-family | Font fallback is supported | — | |
line-height | Lengths and unitless multipliers are supported. Line spacing after wrapping is supported. For example, a 24px font size with 1.5 yields 36px of line spacing | — | |
vertical-align | baseline, top, bottom, middle, and length offsets | — | |
font-weight | Supported | — | |
font-stretch | Supported | — | |
font-variation-settings | Supported | — | |
font-feature-settings | Supported | — | |
font-variant | normal, none, small-caps | The font must provide the corresponding OpenType features. Missing features are not synthesized | |
font-variant-ligatures | normal, none, common-ligatures, no-common-ligatures, discretionary-ligatures | The font must provide the corresponding OpenType features. Missing features are not synthesized | |
font-variant-numeric | normal, oldstyle-nums, proportional-nums, diagonal-fractions, ordinal, slashed-zero | The font must provide the corresponding OpenType features. Missing features are not synthesized | |
font-variant-east-asian | normal, jis83, jis90, full-width, proportional-width | The font must provide the corresponding OpenType features. Missing features are not synthesized | |
font-variant-caps | normal, small-caps, all-small-caps, petite-caps, all-petite-caps | The font must provide the corresponding OpenType features. Missing features are not synthesized | |
font-variant-position | normal, sub, super | The font must provide the corresponding OpenType features. Missing features are not synthesized | |
font-kerning | auto, normal, none | The font must provide the corresponding OpenType features. Missing features are not synthesized | |
font-synthesis | none, weight, style | Does not support small-caps | |
font-synthesis-weight | auto, none | — | |
font-synthesis-style | auto, none | — | |
line-clamp | A number | A custom truncation marker is treated as an ordinary ellipsis. Use block-ellipsis to set a custom marker | |
max-lines | none, 1, 2, 3 | Use with continue: collapse to limit the number of lines | |
block-ellipsis | none (no marker), auto (ellipsis), "END" (displays END) | Use with max-lines and continue: collapse | |
continue | normal, collapse. These keep the following content or truncate at max-lines, respectively | — | |
text-align | left, right, center, start, end, justify | — | |
text-indent | Lengths and percentages (including negative values). Only the first line is indented | — | |
tab-size | 0, 2, 4, 8 | When tab characters are preserved, each tab expands to the corresponding number of spaces. This differs from how browsers align to tab stops | |
text-fit | none, grow, shrink. For single-line text, these respectively keep the original font size, enlarge short text, or shrink overflowing long text to fit the container | — | |
letter-spacing | Supported | — | |
word-spacing | Supported | — | |
overflow-wrap | normal, break-word, anywhere | — | |
word-break | normal, break-all, keep-all, break-word | — | |
white-space | normal, nowrap, pre, pre-wrap, pre-line, <text-wrap-mode> <white-space-collapse>. nowrap prevents soft wrapping, collapses consecutive white space, and preserves explicit br line breaks | — | |
white-space-collapse | preserve, collapse, preserve-spaces, preserve-breaks | — | |
text-wrap | text-wrap-mode | wrap, nowrap | — |
text-wrap-style | auto, balance, pretty | — | |
box-sizing | content-box, border-box | — | |
opacity | Supported | — | |
image-rendering | auto, smooth, pixelated | — | |
filter | blur(), brightness(), grayscale(), hue-rotate(), invert(), opacity(), saturate(), sepia(), drop-shadow(), none. Function combinations are supported | Does not support contrast() or url() (including local fragments and external SVG) | |
backdrop-filter | blur(), brightness(), contrast(), grayscale(), hue-rotate(), invert(), opacity(), saturate(), sepia(), drop-shadow(), none, and function combinations. Applies to content behind the covered area | Does not support url() (including local fragments and external SVG) | |
-webkit-text-stroke | -webkit-text-stroke-width, -webkit-text-stroke-color, -webkit-text-fill-color | Supported | — |
stroke-linejoin | miter, round, bevel | — | |
text-decoration | text-decoration-line | underline, line-through, overline, underline overline | An overline needs enough line height to avoid being clipped. For a 48px font size, use line-height: 72px |
text-decoration-style | solid, double, dotted, dashed, wavy | A double line needs enough line height. For a 48px font size, use line-height: 72px, and set text-decoration-thickness explicitly | |
text-decoration-color | Supported | — | |
text-decoration-thickness | Supported | — | |
text-decoration-skip-ink | auto, none | — | |
text-underline-offset | auto, 0, 8px, 20%. Percentages are relative to the font size | — | |
text-underline-position | auto, from-font, under | — | |
isolation | auto, isolate | — | |
mix-blend-mode | normal, multiply, screen, darken, lighten, overlay, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color, luminosity | — | |
visibility | visible, hidden | — | |