The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Random padding on top and bottom of the code elements

  • # December 11, 2012 at 7:45 pm

    Hey everyone! I’m experiencing a problem with my [blog]( “blog”). For the <code> inside of the <pre> boxes, there seems to be random padding on the top and on the bottom of it. Below is a url to a screenshot that climaxes my problem. Notice there’s no padding on the right side, a little padding on the left, and a lot of padding on the top and bottom.

    # December 11, 2012 at 8:03 pm

    now that is weird. the reset doesn’t add anything to it.

    # December 11, 2012 at 8:11 pm

    hmmm. u have a line-height that might be the issue:

    code {
    font-family: 'Inconsolata';
    line-height: 20px;
    # December 11, 2012 at 8:13 pm

    @twincy , There’s still padding on the sides. :( Thank you for you help though! Very appreciated.

    # December 11, 2012 at 8:42 pm

    It’s the spaces, tabs, and line returns in your code

    # December 12, 2012 at 3:32 am

    wolfcry is right, it’s a line return causing that issue. So instead of writing your HTML like this:


    You should write it like this:


    # December 12, 2012 at 12:45 pm

    This reply has been reported for inappropriate content.

    Are you wrapping it in “code” tag? If so that’s prob why. Just remove it and only use pre. Like this

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed