Maneuvering two blocks of codes side by side


You are mixing concepts a little here. :slight_smile:

Height and padding have no correlation in most cases. The problem with a fixed height was that you were applying it to fix problems rather than sorting out why things weren’t as you expected. e.g you had not contained floats and had forgotten about margins increasing the space elements take up.

A wrapper will not need a specific height if you have taken care of the elements inside properly.

Of course things like iframes and images need height but any containers that contain text or fluid content should not be a fixed height. Sometimes it may be appropriate to use height if you need to match something explicitly and when there is no danger of that height causing a problem.

Don’t latch on to one concept and think it applies to everything because the methods you use depend heavily on the task on hand.

There is no one size fits all in css which is why some people struggle with it because although some methods may appear to work they may be the wrong methods for the job in hand :slight_smile:


So, if this doesn’t need padding or height, what would get used instead?

.wrapa {
  position: relative;
  width: 606px;

  cursor: pointer;
  margin-top: 8px;
  border: 3px solid #0059dd;
  box-sizing: border-box;


Sorry I’ll have to reply tomorrow as I’m back on a mobile now and can’t see the fiddle ( and I’m too tired now anyway :))


Height is fine on that one as you have no fluid content. I believe I told you this in your original thread about height.

In your original thread you were giving a height to the whole column and to a lot of wraps inside that didn’t need it. You had something like height 1113px which is a magic number and not needed. You were using a height because you forgot to contain the floats.

In some cases height is appropriate but in others it is a bad approach.:slight_smile:


The top margin of 100px works, but the bottom margin is way over 100px inside Chrome.

The bottom margin jumps to 368px

Does this have to do with it being inside jsfiddle?

Do you think jsfiddle / codepen is causing this to occur?

or is there an issue in the codes that’s causing this to happen?

This doesn’t occur inside firefox in jsfiddle, or codepen, only in Chrome, inside jsfiddle or codepen

This one uses flex:

.container {
	display: flex;
	margin:100px auto;

This one uses table:

.container {
  display: table;
  width: 936px;
  margin: 100px auto;
  background: red;

This one uses Grid

.container {
  display: grid;
  grid-gap: 64px;
  grid-template-columns: auto auto;
  width: 936px;
  margin: 100px auto;


Have you tested the code on Chrome without using JSFiddle or CodePen?


overflow: hidden;

Was missing from the codes.

I just figured it out, and updated them with the added code.


Is there a difference between using either one of these?

Does one of them make more sense to use than the other?

.container-right {
  float: right;

.container-right {
  float: left;
  margin: 0 0 0 64px;


How did you come up with the left margin value of 64px?


It was just a number I gave it at the time. Nothing special about it.


That doesn’t sound logical or even based on a best estimate. Why give it a value of 64px at all and not simply have margin: 0 ?


That wouldn’t work, see:

Scroll Right Side:

.container-right {
  float: left;
  margin: 0 0 0 0;


Yes one of those requires a magic number of 64px to put the float at the right of the container and would break should anything be more than a pixel out at anytime (or browsers round up or down).

The float right on the other hand needs no magic number to find its position even if there was a discrepancy in pixel sizes.

It’s obvious that the float right is a better approach not to mention more succinct.


I have a question, if table is being used here:

These properties can be removed then, right?
overflow: hidden;
width: 936px;



.container {
  display: table;
  overflow: hidden;
  width: 936px;
  padding: 25px;
  margin: 100px auto;
  border-radius: 25px;
  border: 2px solid #0059dd;
  background: #000000;

.container-right {
  display: table-cell;
  vertical-align: top;

.container-right {
  padding: 0 0 0 64px;


Table elements are ‘shrink to fit’ so you don’t need a width.

They will be as wide as their content pushes them to be until they reach 100% width.

Overflow :hidden hides the overflow so if you have overflow you want hidden then don’t remove it. On the other hand if you have it in place to contain floats then its not needed on display:table elements as they do that automatically.


oh gosh!
I can’t say for how long I’ve been searching for this topic.

What if the content will be greater than 100%? Can I scale it somehow?
Thank you!

kind regards,


Hi gorgun1983, welcome to the forums!

Please, could you elaborate your question as if it was a new topic but with reference to this thread.

And to what posts in this too long thread are you referring your question?

Aside, I really think this question could be in its own thread. :slight_smile:


Because floats aren’t being used on the containers, overflow:hidden; would not be needed.

If floats were being used on the containers, then overflow:hidden; would be needed.


Overflow:hidden is not needed to contain floats when the parent is display:table because table-cells contain floats without extra mark up (even if you don’t have a cell as such because the browser constructs an anonymous table-cell automatically for every display:table element when none exists).


I got this one right then:

Because floats aren’t being used on the containers, overflow:hidden; would not be needed.