In WordPress Elementor, how to make the caption under a photo no wider than the photo.
- User
In WordPress Elementor, how to make the caption under a photo no wider than the photo.
Assistant
To ensure the caption under a photo in WordPress Elementor is no wider than the photo itself, follow these steps:
Method 1: Using Elementor’s Built-in Caption
-
Add an Image Widget
- Drag and drop the Image widget into your Elementor section.
- Upload or select your image.
-
Enable Caption
- In the Image Settings panel, go to the Content tab.
- Under Caption, select Attachment Caption (if using WordPress media library captions) or enter a custom caption in the Custom Caption field.
-
Adjust Caption Width
- The caption will automatically inherit the width of the image if it’s set to Inline (default behavior).
- If the caption is wider, check if the image has a maximum width set (e.g.,
max-width: 100%).
Method 2: Manual Caption (Using Text Widget)
If you’re adding a caption manually (e.g., with a Text Editor widget below the image):
-
Wrap the Image and Caption in a Container
- Add a Container or Inner Section widget.
- Place the Image widget and a Text Editor widget (for the caption) inside it.
-
Set Maximum Width for the Container
- Select the Container or Inner Section.
- Go to Advanced > Custom CSS and add:
max-width: fit-content; margin: 0 auto; /* Optional: Centers the container */ - Alternatively, set a fixed width matching the image dimensions.
-
Style the Caption
- Select the Text Editor widget (caption).
- In the Advanced tab, ensure:
- Width is set to
100%(default). - Padding and Margin are adjusted if needed.
- Width is set to
Method 3: Custom CSS (For Advanced Users)
If the caption still overflows, add this CSS in Elementor > Custom CSS or WordPress Customizer:
.elementor-image-caption { max-width: 100%; display: inline-block; }Or, if using a custom container:
.your-container-class .elementor-widget-text-editor { width: 100%; max-width: 100%; }Why This Happens
- Captions may stretch if the parent container is wider than the image.
- Some themes add extra padding/margin to captions.
Verification
- Preview the page and inspect the caption with browser tools (right-click > Inspect).
- Ensure no conflicting CSS is forcing a wider layout.
This should keep your caption neatly aligned with the image width. Let me know if you need further adjustments! 🚀
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.