All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

How to remove the space between inline and inline-block elements?

This content has been automatically translated from Ukrainian.
To remove the gap between `inline` and `inline-block` elements, one of the methods below may work for you:
Method 1.
Set a zero value for the `font-size` property for the parent element. For example:
.parent-element {
  font-size: 0;
}
This will eliminate the gap that usually occurs due to spaces between "inline" elements.
Method 2. 
HTML comments between elements:
<div class="parent-element">
  <div class="child-element"></div><!--
  --><div class="child-element"></div>
</div>
Inserting the comment `<!-- -->` between elements will help remove the gap.
Method 3.
Write the code without line breaks (in one line)
<div class="child-element"><div class="child-element"></div>
Method 4.
Use `float` instead of `inline-block`. For example:
.child-element {
  float: left;
}
Setting `float: left` for child elements can remove the gap between them.
Method 5.
Negative values for the `margin` property. For example:
.child-element {
  margin-right: -4px;
}
Setting a negative `margin-right` value for child elements can also help bring them closer together (remove the gap between them).
You can experiment with these approaches, choosing the one that best fits your specific situation. Note that each approach may impact the placement and appearance of elements, so be sure to check the results carefully after making changes. Also, remember to encapsulate your code to avoid affecting other objects on the page.

This post doesn't have any additions from the author yet.

03 May 17:46

What to do if the webcam is not working on macOS?

meme code
meme code@memecode
03 May 18:48

How to get a random logical value true or false in Ruby?

meme code
meme code@memecode
06 May 09:19

How to disable File Upload in the Trix editor?

meme code
meme code@memecode
10 May 17:40

How to use hex color codes in CSS with alpha values?

meme code
meme code@memecode
16 May 20:02

What is Origin in Git?

meme code
meme code@memecode
17 May 18:52

What is a loop in Javascript? How do for and while loops work in Javascript?

meme code
meme code@memecode
22 May 16:26

What is the difference between <%, <%=, <%# and -%> in ERB templates (Ruby on Rails)?

meme code
meme code@memecode
23 May 06:57

What is debugging?

meme code
meme code@memecode
23 May 07:41

What are attr_accessor, attr_reader, and attr_writer in Ruby? What are they used for?

meme code
meme code@memecode
23 May 11:16

How does the has_many through association (many to many) work in Ruby on Rails?

meme code
meme code@memecode
24 May 18:53

What are joins in Ruby on Rails and how does it work?

meme code
meme code@memecode