HTML5 div to place the img tag, div bottom border and picture Bottom has a certain distance

Source: Internet
Author: User
WORKAROUND: Set IMG's Vertical-align property to "middle".
Reason:

Down vote favorite 7

I am trying to create a layout where the vertical spacing between divs is pixel perfect. So far I ' ve ruled out of almost all of the big grid systems (960.gs, Blueprint), because they, have no solution in all for the VE Rtical spacings. With them, the ' only way to set vertical spacing between divs ' to ' use ' body {Line-height} attribute and manipulate the D iv spacing using that. I wouldn ' t call so a solution, as it ruins your template, depends on font-family, and doesn ' t we use different SPAC Ings for different divs.

The only grid system I found which has proper support for vertical spacing are Golden grid, which doesn ' t use body {line-h Eight}, but has it ' s own. Clear {height:5px} for vertical spacing.

My problem are that no matter I try, I couldn ' t make spacing work in HTML5. I am talking about vertically arranged images without gap between them. In XHTML transitional mode, everything works perfecly, the images align perfectly, but as in HTML5 mode, they have a ver Tical gap between them. The gap is 2px in Chrome and 2-3 px in Firefox, alternating between lines. I am It's the case with every grid system then used in HTML5 mode. I don ' t know what ' s best way to write this code in plain HTML5, so I just tried grid systems. The vertical gap is present in 960.gs, Blueprint too.

A solution I found out might is to set body {line-height:0} and define line-height in every single typographic tag. But I don ' t understand why such a bad hack would is required for such a simple case:vertically arranged. Why are browsers different in HTML5 mode than in XHTML transitional mode?

Here, I have the same page, nothing changed, just the DOCTYPE. The XHTML one is pixel perfect in every browser, the HTML5 one has the gap and are different from browser to browser.

What is the best way to make the HTML5 example work like the XHTML transitional one?

Update:thirtydot answered the problem, if I include img {display:block;} The HTML5 version behaves exactly the same as The XHTML transitional. Thank you thirtydot!

But before closing this thread, can someone explain to me why are it that:why do all browsers behave differently in HTML5 mode and all have different vertical gaps between IMG elements, while not specified as Display:block. Have a browser comparing site for the HTML5 link above, it'll be different from browser to browser. They have gaps between 2 to 4 px. Why does XHTML transitional not need this hack Why does XHTML Strict produce a vertical gap too are it safe to use img {di Splay:block; } In a reset.css sheet?




Down vote favorite 7

I am trying to create a layout where the vertical spacing between divs is pixel perfect. So far I ' ve ruled out of almost all of the big grid systems (960.gs, Blueprint), because they, have no solution in all for the VE Rtical spacings. With them, the ' only way to set vertical spacing between divs ' to ' use ' body {Line-height} attribute and manipulate the D iv spacing using that. I wouldn ' t call so a solution, as it ruins your template, depends on font-family, and doesn ' t we use different SPAC Ings for different divs.

The only grid system I found which has proper support for vertical spacing are Golden grid, which doesn ' t use body {line-h Eight}, but has it ' s own. Clear {height:5px} for vertical spacing.

My problem are that no matter I try, I couldn ' t make spacing work in HTML5. I am talking about vertically arranged images without gap between them. In XHTML transitional mode, everything works perfecly, the images align perfectly, but as in HTML5 mode, they have a ver Tical gap between them. The gap is 2px in Chrome and 2-3 px in Firefox, alternating between lines. I am It's the case with every grid system then used in HTML5 mode. I don ' t know what ' s best way to write this code in plain HTML5, so I just tried grid systems. The vertical gap is present in 960.gs, Blueprint too.

A solution I found out might is to set body {line-height:0} and define line-height in every single typographic tag. But I don ' t understand why such a bad hack would is required for such a simple case:vertically arranged. Why are browsers different in HTML5 mode than in XHTML transitional mode?

Here, I have the same page, nothing changed, just the DOCTYPE. The XHTML one is pixel perfect in every browser, the HTML5 one has the gap and are different from browser to browser.

What is the best way to make the HTML5 example work like the XHTML transitional one?

UPDATE: Thirtydot answered the problem, if I include img {display:block;} The HTML5 version behaves exactly th E Same as the XHTML transitional. Thank you thirtydot!

But before closing this thread, can someone explain to me why are it that:why do all browsers behave in HT ML5 mode and all have different vertical gaps between IMG elements, while not specified as Display:block. Have a browser comparing site for the HTML5 link above, it'll be different from browser to browser. They have gaps between 2 to 4 px. Why does XHTML transitional not need this hack Why does XHTML Strict produce a vertical gap too are it safe to use img {di Splay:block; } In a reset.css sheet?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.