☰
ELEMENTOR / PRACTICE

How to Align an Icon and Text in an Elementor Button

How to Align an Icon and Text in an Elementor Button

An icon in an Elementor button can look misaligned even when the button itself has the correct alignment. The issue is most often related to differences between the font and icon heights, the line-height value, default spacing between elements, or styles added by the theme.

For a stable result, convert the button to a flex container and align its inner wrapper and icon separately. Below, you will find ready-to-use CSS, instructions for adding it, ways to test the button on different screen sizes, and solutions to common issues.

Why an Icon in an Elementor Button Looks Misaligned

Visual misalignment does not always indicate an Elementor error. Button text is aligned according to the font metrics, while an icon may have a different height, its own line-height, or additional spacing. As a result, the center of the text and the center of the graphic symbol may not match.

Another possible cause is the default margin between the icon and label. If you add a gap with CSS on top of that margin, the space will become too large. A similar effect can occur when the theme or another plugin changes the styles of .elementor-button.

  • different line-height values for the text and icon;
  • vertical alignment to the baseline instead of the center;
  • default margin on the icon container;
  • long text, line wrapping, or different label lengths in different languages;
  • style conflicts from the theme, a plugin, or custom CSS.

How to Add CSS for an Elementor Button

If your version of Elementor provides a Custom CSS field for the Button widget, open the relevant button, go to its advanced settings, and add the code to the widget's CSS field. In this field, the selector automatically refers to the current element, so the styles should not affect every button on the site.

Before making changes, it is best to save the page and check the result in preview mode. If the Custom CSS field is unavailable, you can apply the same principle through the theme's CSS or a dedicated style block. In that case, restrict the rule to the class of the specific button so that other elements are not affected.

  • select the Button widget itself, not the parent section;
  • check whether the CSS is being applied to the current widget;
  • clear the cache after saving if the changes do not appear immediately;
  • do not add !important unless necessary: the exception in the code below is used only to cancel the icon's default margin.
selector .elementor-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.2;
}

selector .elementor-button-content-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

selector .elementor-button-icon {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  margin-inline-end: 0 !important;
}

How This Code Works

The display: inline-flex property turns the button into a flex element that retains inline-block behavior while allowing you to control its internal alignment. align-items: center centers the content vertically, while justify-content: center centers it horizontally.

The gap property creates consistent spacing between the icon and text without manual positioning. A value of 8 px is a practical starting point, but you can adjust it to match the design. For example, 4–6 px may suit a compact button, while a large button with a substantial icon may require more.

Flex alignment is repeated in .elementor-button-content-wrapper because this inner wrapper often contains the text and icon. For .elementor-button-icon, line-height: 0 removes extra space that could otherwise appear around an inline SVG or icon font.

  • use gap instead of manual margin when the spacing should remain consistent;
  • margin-inline-end works more reliably for different writing directions than margin-right;
  • line-height: 1.2 for the button reduces excess vertical space around the text;
  • if the icon already has its own styles, inspect them using the browser's developer tools.

What to Check in the Button Settings

CSS does not replace the widget's basic settings. First, make sure the icon has actually been added to the button and that its position matches the intended design. Also check the typography: an overly large line-height or unusual font weight can make the icon appear higher or lower.

Review the button's internal padding separately. If the top and bottom padding differ significantly, the entire content may look misaligned even though flex centering is working correctly. For buttons with long labels, avoid setting a fixed height unless necessary: the text may wrap to a second line and change the element's height.

  • compare the button's top and bottom padding;
  • check the font line-height and icon size;
  • make sure no unnecessary margin has been assigned to the text or icon;
  • do not fix the button height if the label may wrap;
  • check whether the icon is being clipped by overflow: hidden.

When to Change the Spacing Between Elements

If the icon and text are correctly positioned after adding the code but there is too much or too little space between them, change the gap value. Do not leave both a large gap and the icon's old margin in place, or the total spacing will consist of both values.

  • reduce both gap values to one consistent setting;
  • keep the margin-inline-end reset if Elementor adds its own spacing;
  • check the result for buttons with the icon on both the left and the right.

Testing the Button on Different Screens

After aligning the button, review it on a desktop, tablet, and smartphone. A narrow screen can change the button's width, cause the text to wrap, or make the icon look too large. Pay particular attention to long labels and translations: Ukrainian, German, or other text may take up more space than a shorter version.

The button should remain easy to tap, stay within the parent container, and avoid overlapping nearby elements. If a different spacing or icon size is needed on mobile, use Elementor's responsive settings or a media query in CSS.

  • test the button in a real mobile browser, not only in the editor;
  • make sure a long label does not create unwanted wrapping;
  • check the hover, focus, and active states;
  • verify that the icon's contrast does not disappear against a colored background;
  • check the buttons in the language versions of the page.

Common Mistakes and How to Fix Them

The most common mistake is applying the code to a section or column instead of the Button widget itself. In that case, selector may refer to the wrong structure, and some rules will not work. Another common issue is using only vertical-align: middle. This property does not provide complete alignment of child elements within the button's flex structure.

If nothing changes after inserting the CSS, open the browser's developer tools and check which rules are crossed out or overridden. The cause may also be cached CSS, file optimization, or styles with greater specificity.

  • do not use transform: translateY() as the primary solution—it only masks the problem;
  • do not manually align the icon with a negative margin without testing other languages and sizes;
  • do not duplicate the CSS in multiple places unnecessarily;
  • after making changes, clear the Elementor, caching plugin, and browser caches if the site uses them;
  • check whether the theme adds its own margin to SVGs or pseudo-elements.

Frequently asked questions

Can I align the icon without Custom CSS?

Sometimes it is enough to adjust the icon position, size, typography, and spacing in the widget itself. If the icon still appears misaligned, flex rules through Custom CSS usually provide a more precise and stable result.

Why did adding gap create double spacing between the icon and text?

The button may still have the icon's default margin. Reduce or cancel that margin, then keep one controlled gap value for the spacing.

Does this code work for a button with the icon on the right?

Yes. The code aligns the elements regardless of their order. Just make sure the icon and text direction matches the button settings and that the margin does not add unwanted spacing.

What should I do if the long text wraps onto two lines?

Check the button width, padding, and line-height. Do not set a fixed height if wrapping is acceptable. If necessary, reduce the font size or create separate responsive settings for mobile screens.

Do I need to use !important for all CSS?

No. !important is needed only when a specific Elementor or theme rule has higher priority. In the example, it is applied to the icon margin to reliably remove the default spacing.

Conclusion

For a button to look properly aligned in Elementor, you need to align not only the button itself but also its inner wrapper and icon. Combining display: inline-flex, align-items: center, a consistent gap, and line-height: 0 for the icon resolves most vertical alignment issues.

After adding the CSS, always check the padding, default margins, long labels, different languages, and mobile version. This approach provides a predictable result without manually positioning the icon with transform or arbitrary negative margins.

← All Elementor materials