Making background colours editable with template tags
In a custom HTML template, the background colours are fixed. If you want the editor to be able to choose a background colour, add the lp-bgcolor attribute to that element, for example to a table or a td.
These tags only apply to an imported HTML template, not to the drag & drop editor. You can read how to import such a template in Importing your own HTML template.
Making a background colour editable with lp-bgcolor
Add lp-bgcolor to the element for which the editor is allowed to choose the background colour. Also give the element a default colour with bgcolor and background-color. That colour remains in place until the editor chooses a different one. When the editor chooses a colour, Laposta sets it in those same two places. A background image remains in place.
Options
Makes the background colour editable. As the value, enter the colours the editor can choose from as comma-separated hex codes, for example lp-bgcolor="#f4f4f4,#ffffff,#1d3557". You can specify up to 12 colours, in the format #rgb or #rrggbb. The editor sees them in the editor as swatches. If you use lp-bgcolor without a value, the editor can choose any colour freely.
The name of the colour setting, for example lp-bgcolor-name="page". With this name, you can give other elements the same colour using lp-bgcolor-follow. A name starts with a letter and contains only letters, digits and hyphens, up to 30 characters. Give every setting a name. Without a name, a chosen colour may end up on a different setting after re-importing the template.
The name the editor sees next to the colour in the editor, for example lp-bgcolor-label="Background". Without a label, the editor sees the name from lp-bgcolor-name, and without a name, the words Background color. Do not use lp-label for this: that does not work for a background colour.
Gives this element the same colour as the setting with this name, for example lp-bgcolor-follow="page". If the editor chooses a different colour for the page setting, this element changes along with it.
Example
In this example, the editor can choose the colour of a table from three colours:
Using the same colour in multiple places with lp-bgcolor-follow
Often, the same colour is used in multiple places, such as on the body and on the outer cell of each block. Add lp-bgcolor-follow there, with the name of the setting. Only elements with this attribute adopt the chosen colour. In the example below, the body gets the colour that the editor chooses under ‘Background’.
Example
One colour for the entire email or per block
If lp-bgcolor is outside an <lp-repeater>, the editor chooses one colour for the entire email. That colour is located in the sidebar of the editor under ‘Colors’.
If lp-bgcolor is inside an <lp-layout>, the editor chooses a colour per block. This is done using the palette icon in the block menu.
With ‘Default’, the editor resets the colour to the one from the template.
An lp-bgcolor-follow inside a block first looks up the name among the colours for the entire email and then within the block itself. This gives the outer cell of every block the page colour, including in blocks that the editor adds later.
Do not reuse the name of a colour for the entire email inside a layout. The block will not get its own colour in that case.
Colours in sublayouts
With sublayouts, the editor can switch between variants within a single block, for example a text block with and without a button. If you want the chosen colour to remain when the editor switches variants, give the colour the same name and the same colour list in each sublayout.
If the editor chooses light yellow (#fff3d6) in the first variant and switches to the second, the block stays light yellow.
Two things differ between the values of lp-sublayout-content on the layout:
- With
shared(the default), each variant can have its own colour list. If the chosen colour is not in the list of the other variant, that variant gets the colour from the template again. Here, anlp-bgcolor-followin a variant only finds the colours for the entire email and those in its own variant. - With
individual, a name applies across all variants together. In that case, give the colour the same list everywhere, or place it in one variant and uselp-bgcolor-followin the others.
A complete example
This template has a page colour from a list, a header in a free colour and text blocks with their own colour per block. You can import it to try it out.
Things to keep in mind
- Only use hex colours. Names such as
whiteorrgb(...)are skipped by Laposta. - Do not place the attributes on
<html>, on Laposta tags such as<lp-layout>, inside an<lp-multiline>or inside conditional comments for Outlook (<!--[if mso]>). They do not work there. - If the text colour is fixed, provide a list of suitable colours. With a free choice, the editor might pick a colour on which the text is hard to read.
- Do not use
!importantfor a background colour in a<style>block, not even for mobile or dark mode. Such a rule overrides the colour the editor chooses. In email clients that use the rule, the old colour will then remain. If you have the CSS inline placed, the old colour will remain in all email clients. - If an element without
lp-bgcolororlp-bgcolor-followgets its background colour from a<style>block, it keeps the colour from the template. If the editor chooses a different colour, you will see two colours next to each other. Therefore, also addlp-bgcolor-followto such an element. - An Outlook background in VML (
v:background,v:fill) keeps the old colour in Outlook for Windows. - In dark mode, the email client may adjust the colour.
Warnings during import
If something is not right, for example an lp-bgcolor-follow with a name that does not exist or a name that occurs twice, you will see a warning in the import report. The import will still go ahead. Adjust your HTML and import the template again.
Test a template with background colours just like any custom template: choose a different colour in the editor and send a testmail to the email clients that are important to you.