Tutorialspoint.dev

How to remove the space between inline-block elements?

To remove the space between the inline-block element use margin-right property. This property is used to remove the space between their right positioned element. This property generated negative values to remain close to their adjacent element.

Syntax:

element { 
    margin-right:value;
 }

Example:

<!DOCTYPE html>
<html>
    <head>
        <style>
            nav a {
                display: inline-block;
                margin-right:-4px;
                background: green;
                color:white;
                font-weight:bold;
                text-decoration:none;
            }
            h1 {
                color:green;
            }
            body {
                text-align:center;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>margin-right:-4px;</h2>
        <nav>
            <a href="#"> geeks </a>
            <a href="#"> for </a>
            <a href="#"> geeks </a>
        </nav>
    </body>
</html>                                            

Output:

Supported Browsers: The browser supported by CSS margin property are listed below:

  • Apple Safari 3.1
  • Google Chrome 4.0
  • Firefox 3.0
  • Opera 7.6
  • Internet Explorer 8.0


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter