WordPress: How to add a background image to a post


With some CSS knowledge you can add a background image to a blog post in WordPress. In this post, I have set the image width to 100% and the height to the actual number of pixels. For the text, I chose a white text box. See the code below the image.

You can add several text boxes. If you want to use a background color (for instance red) rather than an image, this is the code: <div style="background-color:red">


Image: iStock.com/mirjanajovic


<div style="background-image:url('image URL');width:100%;height:actual_number_of_px;background-position:center;background-repeat:no-repeat;">
This is the code for the text box:
<div style="margin:15px 25px 0;text-align:left;padding:25px 25px 8px;background-color:#ffffff;">
Here you type your text.

Share your thoughts:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s