Tuesday, September 30, 2014

Techie Tuesday: Centering Third-Party Media Ads

Today’s question comes for Audrey of Audrey Salutes, “how do I center my third-party media ads in my widget?”  

Third-party media ads are ads you would use from Rewardstyle, Glam or Blogher. Most bloggers express a lot of frustration when trying to set them up. Ads. Often, everything in the sidebar will be centered besides it.

First, you want to make sure you’ve selected an ad that fits your widget sidebar. Most sidebars fit ads that are 300x200px or 160x60px. Pixel height of your ad doesn’t matter as much as width. You don’t want to put an ad that is wider than your sidebar. I should note: if your blog is not built responsively to images and videos, you are going to have a bad time, especially for mobile and tablet versions. You are making these edits in the following areas. If you have WordPress, Appearances < Widgets  (see image below for reference). If you have blogger, in the html/javascript gadgets of Layout in the dashboard.

Most bloggers try to use this method to center their ad:
<center>
AD CODE
</center> 

While it is accurate, it is not the best practice. Your ad is interactive and functioning feature. It needs to be placed in a <div>. This option works most of the time:
<div style="text-align: center;">
AD CODE
</div>




Occasionally, ads can be extremely strange and center some of the time. One way to prevent is this is to assign a "display:block" to your <div>. Thus, you would have:
<div style="display: block; text-align: center;">
AD CODE
</div>

What is “display: block”? Without getting too complicated, assigning a block level display to an element (your ad) means that the browser will display line breaks before and after the . The will take up the full-width of the available space, and the elements in it with be now centered. If you want to align your elements left or right, simply replace “center” with either/or.

Do you have tech or design questions you would like answered? "Techie Tuesdays" is a weekly series written by Lindsay Humes of White Oak Creative. In order to make this series as beneficial to Midwest Bloggers, you can email your specific questions to Lindsay at hello@whiteoakcreative.com, and she will answer them in her weekly series.

No comments:

Post a Comment