0

Having a problem with inline, block, and in-line block. What are there differences?

body{
        width: 100%;
        height: 100%;
        background: #3D3D3D;
    }
    span,h2{
        color:green;
    }
    .main{
        font-family: Arial !important;
        text-align: center;
        margin: 0 auto;
        width: 960px;
        min-height: 920px;
        background: #FFF;
    }
    .header{
    display: inline;

    }

    .logo{
    float: left;
    display:inline;
    }
    .contact {
    float: right;
    display:block;
    margin: 0 10px 0 0;
    color: #525252; font-size: 11px;
    }

    .contact img {position: relative; top: 8px;}

    nav{
        float: right;
        clear: both;
        display:inline-block;
        padding: 0 10px;
    }
    nav ul{
    list-style-type: none;
    float: left;
    margin: 0;
    height: 35px;
    }

    nav li{
    float: left;    
    }
    nav a:link, a:visited{
        background-image: url(images/bg_nav.jpg);
        background-repeat: repeat;      
        padding: 0;
        border-top-left-radius: 6px;
        border-top-right-radius: 6px;
    }
    nav a{
        display: block;
        color: white;
        text-align: center;
        padding: 0;
        margin: 0 0 0 5px;
        text-decoration: none;
        width: 105px;
        height: 35px;
        line-height: 35px;
    }
    nav a:hover{
        background-image: url(images/bg_hover.jpg);
        background-repeat: repeat;  
    }
    .banner{
        display: block;
        margin: 0;  
    }

    .slideshow { 
    display: inline-block;
    }
    .slideshow img { 
            background-color: #eee; 
    }

    .content{
        display: block;
        width:690px;
        float: left;
        text-align: left;
        padding: 0 10px;

    }

    .content h1 {font-size: 15px; color: #545454;}
    .content h1 span {color: #066324;}

    .content p {font-size: 12px; color: #545454; line-height: 200%;}

    .features img{
        display: inline-block;
    }


    .sidebar{
        float: right;
        padding: 0 10px;
        width: 230px;
    }
    .form-body{
        background-image: url(images/form_bg.jpg);
        background-repeat: repeat;
        padding: 10px 0;
        margin: 0 auto;
        width: 230px;
        float: left;
    }
    .input-form{
        text-align: left;
        height: 30px;
        width: 175px;
        background-image: url(images/contactbg.jpg);
        background-repeat: repeat;
        border:0;
        margin-bottom: 10px;
    }
    .input-message{
        text-align: left;
        height: 75px;
        width: 175px;
        background-image: url(images/contactbg.jpg);
        background-repeat: repeat;
        border:0;
        margin-bottom: 10px;
    }
    .image-button{
        background-image: url(images/bg_hover.jpg);
        background-repeat: repeat;
        height: 30px;
        width: 70px;
        color: white;
        border-radius: 8px;
        display: block;
        text-align: center;
        padding: 0;
        float: right;
    }
j08691
  • 204,283
  • 31
  • 260
  • 272
  • 2
    Read The Fantastic Manuals: https://developer.mozilla.org/en-US/docs/Web/CSS/display and http://www.w3.org/TR/CSS2/visuren.html#display-prop – j08691 Jun 19 '14 at 16:44
  • 1
    [That's a good one too](http://stackoverflow.com/a/9189873/3444240) – potashin Jun 19 '14 at 16:45

1 Answers1

0

I find it helps to visualise them by seeing what elements use them by default.

Inline elements are things like <b> or <span> - usually text styling elements with no width and height. Block elements are things like <div> or <ul> - which are usually rectangular areas with a width of 100%. Images behave as block-inline, which is similar to a block but with a width and height.

To some extent (though not literally) "display:inline" is saying "behave as text", and "display:block" is saying "behave as a rectangle".

RichardB
  • 2,615
  • 1
  • 11
  • 14