What exactly does [.wrap] do?

What exactly does this line of code do, and how come I don’t see a visual difference when I remove it? And if there is a visual difference can someone point it out to me cause I don’t see it.

With Wrap http://withwrap7654.blogspot.com/
https://jsfiddle.net/a1gspkak/9/

Without Wrap http://withoutwrap8765.blogspot.com/
https://jsfiddle.net/a1gspkak/10/

.wrap {
display:table-cell;
table-layout:fixed;
border-spacing:0px;
width:100%;
max-width:1206px;
margin:auto;
border: 0px solid red;
}

There is no visible with the above CSS or without it because most of the properties cannot be applied to a tablle-cell, they are table properties. In other words, they are not doing anything.

The table-rows are part of the structure of a table and are supposed to follow a table element, not follow a table-cell.

.wrap should be assigned {display:table}

I just did that, changed table-cell to table, and there’s still no visual difference.

border-collapse:collapse; also works when you apply it to outer.

Is there a difference between adding it to .wrap or .outer?

.outer {
display:table;
height:100%;
margin:0 auto; 
border-collapse:collapse;
}

That doesn’t mean that it makes no difference. :slight_smile:

Add {border-collapse:collapse} to .wrap. border-collapse only acts on tables. You should see a difference when .wrap is set to display:table;border-collapse:collapse. Then change display:table back to display:table-cell and see what changes, then remove the CSS entirely and watch nothing change again.

The reason your display is not changing is because browsers are creating anonymous table elements that happen to work.

Is there a difference between adding it to .wrap or .outer?

.outer and .wrap are two different elements that have been assigned {display:table}, so yes, there is a difference. Border-collapse only affects the table to which it is assigned. If the selector targets all tables, then all tables are affected.

1 Like

Border collapse has an effect on tcell also. That works too. Wouldn’t that be the ideal place to put it, tcell?

.tcell {
  border-collapse: collapse;
 }

No it doesn’t.

No it wouldn’t. border-collapse affects ALL of the cells within a table the same. It does not affect them differently.

Border collapse works when you put it on tcell. Are you saying it doesn’t work when you put it on tcell?

The image is not proof. Working code would be the proof.

Yes, I am saying exactly that.

Working code: Border collapse on tcell.

.tcell {
display:table-cell;
vertical-align:middle;
border-collapse:collapse;
}

It is doing nothing because it is in the “tcell”, HOWEVER, it is being inherited by .wrap and applied to .wrap.

it’s not applied to the .wrap tag element though, that doesn’t matter?

No. Targeting the .wrap tag directly works, of course, and targeting the parent .tcell works because border-collapse is inherited from the parent .tcell (parent element)

1 Like

You can demonstrate that assigning {border-collapse} to a .tcell does nothing by removing it from .outer .tcell and applying it to any of .theBoxes. There will be no collapsing of borders.

Adding it to html,body makes it collapse.

html, body {
height: 100%;
margin:0;
padding:0;
background: #000000;
border-collapse:collapse;
}

Yes, because the body element is the parent of .outer {display:table}

So, it works in 4 spots. I have them in 4 blogger pages, in 4 different spots, and they work in each of them.

tcell, outer, html,body, and wrap,

Yes.

2 Likes