• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Make WP Simple

WordPress Tutorials

  • Blog
  • Getting Started
  • Tutorials
  • Start a Blog Guide

How to Code A Border with a Gap for Text

June 10, 2014 Uncategorized No Comments

This post may contain affiliate links, which means I will receive compensation if you click through and make a purchase.

Styling Borders Around Text

Ever wonder how to get the effect of having a border around a widget, while leaving a gap for a widget title like this:

How to Style a Widget Title with a Border

It’s actually a lot simpler than you would think!

The code below is for Genesis, but you can adapt it for any other theme. Just add the following to your theme’s CSS. Make sure to change the class selectors to match those used in your theme!

1
2
3
4
5
6
7
8
9
10
11
.sidebar .widget {
     background-color: #fff;
     border: 2px solid #000;
}
 
.widget-title {
     background: #fff;
     margin-top: -60px;
     padding: 15px 10px;
     text-align: center;
}

The negative number for margin-top is where the magic happens. The greater the negative number, the higher the widget title will be pulled upwards. This, combined with setting the background color of .widget-title, is essentially what gives the desired effect.

Share
Tweet
Pin268
268 Shares

Reader Interactions

Comments

  1. Brooks says

    June 10, 2014 at 10:45 am

    Love, love this tutorial! Is this also applicable to Blogger?

    Reply
    • Allyssa says

      June 10, 2014 at 11:13 am

      Yes! I’m not too familiar with Blogger, but for the first bit of code, change .sidebar .widget to .widget. For the second part, change .widget-title to .widget h2. I *think* that should work. Again, I’m not too familiar with Blogger, so you might have to play around until you find the correct classes to apply the settings to.

      Reply
      • Brooks says

        June 15, 2014 at 8:24 pm

        I’m having a hard time getting the desired effect of the title being settled between the top line, creating that boxed effect. My titles are completely blocking out the top line of the box. What do I need to do? Thanks!

        Reply
  2. Niki says

    June 10, 2014 at 12:22 pm

    This is so pretty! I am so bad at coding for WordPress but your posts are always so helpful!

    Reply
  3. Emily says

    June 15, 2014 at 4:05 pm

    Thanks so much for sharing this! I used it for my blog redesign and I love it! Thanks again 🙂

    Reply
  4. Kolbi says

    June 15, 2014 at 10:48 pm

    Can you please do an html e-course or something. You have talent! People need your tips & tricks!

    Reply
  5. Noemi says

    June 26, 2014 at 5:38 am

    So pretty!!!
    How can I add this to a single widget (on Blogger)? Thanks for your help!! 🙂

    Reply
    • Allyssa says

      July 14, 2014 at 2:58 pm

      Hi Noemi. I’m really not that familiar with Blogger, but you’d have to find out what the class is for a widget title and use that instead of .widget-title. Same goes for the actual widget itself, which you’d have to sub in for .sidebar .widget. You can use a browser extension called Firebug to help you find the classes.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Looking for Something?

FREE Start a Blog Checklist



GET IT

This site is powered by:

Footer

  • Free Start a Blog Guide
  • Getting Started
  • Tutorials
  • Tools & Resources
  • Website Strategy
  • All Tips & Tutorials
  • About
  • Subscribe
  • Get Help
  • Contact

© 2019 Italicized Creative LLC. Privacy Policy. Terms of Use.