element: To shorten the code, it is possible to specify all the padding properties in
Now for some applications this is fine, but when it comes down to pixel perfect layout mo-jo, it has a few downsides: 1. You know what is 100% bullet-proof? If you want to align the children centered you need to define a width for the parent element which is not possible in every case. By the way, when using it, it makes sense to use `rem`-unit font-size for child elements to keep layout em-aware. Maybe this comes in handy some time. wow and lol this post gets a lot of attention. The negative margin method doesn’t work quite right in Firefox. Could someone e-mail the link on how to avoid whitespaces between news blocks in Dreamweaver? @Landis and @Julian: You guys may want to reconsider the negative margin technique. I think it’s just habit, and no one has come along, kicked them in the arse and told them to break it. isn’t it a best practice to compress / minify HTML anyway? It’s a layout with lots of Liquid inside, that removes all the unnessecary whitespaces during the rendering. If you have to, use the comment method or don’t use carriage returns between elements. Afaik, there seems to be at least two ways: One is to use a custom font with spaces character of zero width; should be working fine and I think we can easily add a custom whitespace, in the case we are already using a font via @font-face. I made a demo for you to see here: jsFiddle Negative Margin Trick. Also: with html comments watch out for the duplicate char bug http://www.positioniseverything.net/explorer/dup-characters.html This bugs in Firefox in floats, so better separate letter-spacing to Webkit-only browsers. To create extra spaces before, after, or in-between your text, use the (non-breaking space) extended HTML character. I use inline-block with close and open tags butting up to one another. The word-spacing property is used to specify the space between the words in a text. It’s the most reliable method imo. I think setting the font size to 0 is the optimal solution here, and also the cleanest. I’ve used the negative margin, but seeing as it breaks in IE 6 & 7 and can pose problems with things off to its right. In this article, we will cover all the possible ways to set the vertical space between the list of items. ;-). “The element is closed on the occurrence of the next or element.”. Thanks a lot for the idea of using rem units to restore the ability to resize the font of inline-blocks after zero-fonr trick! IE9). ... (CSS spacing properties) to add the spacing you need. @Justin, we don’t need to clear float if we set the parent element to have overflow hidden, so no need for clearfixes. I have been avoiding inline-block for a long time because of IEs and hate to use zoom fix. padding-bottom. Negative margin hack is probably taken from my CSS Box Framework https://github.com/vladocar/Box-CSS-Framework/blob/master/box.css at least I think that I was first to “invent” that hack. The example white-space issue Chris used above is really easy to fix without even having to worry about white-space — just put the red background on the ul and you’re done. :). The negative margin should also present problems because not all browsers calculate the white-space exactly the same. Either way, the fix is so much easier than everyone is making it out. You can scoot the elements back into place with negative 4px of margin (may need to be adjusted based on font size of parent). I believe pad/phone sites done sized w/ media queries are sucessfully done via inline-block. There is lots of information in the README, so I won’t go into details here. Using an em value seems to works across systems, though I forget the exact value right now…, Awesome article..i came across that type of list but didnt knew the reason..now i know :) hope u wont mind if i write this trick up in my blog..Not to mention, i will have a back link to this post ;) awesome stuff. http://jsfiddle.net/kpadx/27/. Nearly all developers use float rather than inline-block. Since HTML5 allows closing list item tags to be omitted, then the spacing should still be preserved. Place the image in a block element with a style=”line-height:10px” or equal to the image height. I would have never imagined that a line break in the code would count as white space when rendering. with floats we might need to clear the float with some addition unnessecary html something like . The spaces between inline-blocks are no different. Here’s the big reveal: I rarely ever have to deal with the whitespace issue discussed here, and that’s because it’s easy to design interfaces that don’t require zero whitespace between elements. I just don’t like the idea of leaving out closing tags and am not looking forward to working with code where they are left out just because they can be. It would be cool to have some serious, extensive testing on them. Worst case scenario, just use floats, but I’ll tell you that I use floats so infrequently, that I’ve nearly forgotten how to clear them :). How do I Increase/Decrease the Space Between Paragraphs on a Web Page (CSS) by Christopher Heng, thesitewizard.com. Using negative margin too, think that’s best because you are actually adjusting the elements position. Here, the
element is given a width of 300px. I hadn’t come across the negative margin before. I’m going to assume you pretty much exclusively use float and rarely (or never) use inline-block, and because of this, float seems simple because it’s familiar to you, it’s comfortable. padding-right. Pixel perfection (I’m assuming your mean zero spacing) CAN be achieved with inline-block. I suggest you to start by dropping entirely Dreamweaver (it’s not useful anymore, just a waste of PC resources). With inline-block, there are two issues that can come up (this article address one), they are predictable and their solutions are easy.
- one
- two
- three