2

Is it possible to add spacing between the cells?

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>test</title> <style> #wrap { display: table-row; /* there is no also cellspacing in CSS afaik :( */ } #wrap div { display: table-cell; /* margin: 40px; doesn't work for table-cell :( */ /* border: 30px solid transparent; works but it's as good as adding padding */ /* border: 30px solid white; works but the page background is invisible */ /* decoration: */ background-color: green; padding: 20px; } </style> </head> <body> <!-- don't touch the markup --> <div id="wrap"> <div>text1</div> <div>text2</div> </div> </body> </html> 
1

1 Answer 1

4

Use margin property:

#wrap div { background-color:green; float:left; margin:10px; padding:20px; } 

If this is not exactly what you want to achieve, please let me know so that I can help.

Edit: Another approach is to do this:

#wrap { border-spacing:20px; display:inline-table; } 

but note that border-spacing is not fully supported on all browsers (IE6 & IE7 does not support it).

Sign up to request clarification or add additional context in comments.

2 Comments

i liked your first solution with "border-spacing" better because float will drive me into the clear hell. too bad there is no "border-spacing-left"
margin does not work on items displayed as a table-cell. In the event the user wants to build a variable row of N items that automatically fill the space they are given, you need table-cell until a newer CSS feature becomes widely supported. In this case, only your second answer applies, and it would be great if you could clarify this.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.