Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line breaks in HTML wrecks labels' horizontal size and spacing #14081

Closed
Yardboy opened this issue Jul 8, 2014 · 8 comments
Closed

Line breaks in HTML wrecks labels' horizontal size and spacing #14081

Yardboy opened this issue Jul 8, 2014 · 8 comments
Labels

Comments

@Yardboy
Copy link

Yardboy commented Jul 8, 2014

The two snippets below are identical except for the line breaks around the content, yet they produce different output in the browser. The line breaks in the second snippet affect the horizontal spacing of the labels, as shown in the images below.

It specifically seems to be related to the line break that comes AFTER the content, as demonstrated here: http://jsbin.com/dufiquge/1/edit?html,output.

<div class='label label-primary'>label 1</div>
<div class='label label-info'>label 2</div>
<div class='label label-success'>label 3</div>
<div class='label label-primary'>
  Label 1
</div>
<div class='label label-info'>
  Label 2
</div>
<div class='label label-success'>
  Label 3
</div>

buttons1

buttons2

@cvrebert
Copy link
Collaborator

cvrebert commented Jul 8, 2014

You should be using spans instead of divs.

@cvrebert cvrebert added the css label Jul 8, 2014
@twbs-lmvtfy
Copy link

Hi @Yardboy!

You appear to have posted a live example (http://jsbin.com/dufiquge/2), which is always a good first step. However, according to the HTML5 validator, your example has some validation errors, which might be causing your issue:

  • line 58, column 11: Stray end tag span.
  • line 84, column 7: End tag for body seen, but there were unclosed elements.
  • line 29, column 27: Unclosed element div.

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!

(Please note that this is a fully automated comment.)

@Yardboy
Copy link
Author

Yardboy commented Jul 8, 2014

Thanks, you're right I should be using spans instead of divs.

However, the problem exists with spans as well: http://jsbin.com/dufiquge/2/edit?html,output

@mdo
Copy link
Member

mdo commented Jul 8, 2014

Labels are inline, and this is just how the browser is rendering the white space in your code. It's no different for any other element as far as I know.

@Yardboy
Copy link
Author

Yardboy commented Jul 8, 2014

However, it's not just white space/spacing - look at the blown up image in the OP above, the horizontal size of two of the labels actually changes. It seems to be specifically related to the line break, see this version of the jsbin where I've removed all white space on the problem code except for the line break: http://jsbin.com/dufiquge/4/edit?html,output

@mdo
Copy link
Member

mdo commented Jul 8, 2014

Yeah, it's where the white space from how HTML is rendered is applied. When there are line breaks within the opening and closing tags, it's within. When there are no line breaks around the inner content, the white space is on the outside.

@mdo
Copy link
Member

mdo commented Jul 12, 2014

Going to punt this to v4. I want to rework labels—the inline behavior for them is just causing all sorts of problems.

@mdo mdo closed this as completed Jul 12, 2014
@Yardboy
Copy link
Author

Yardboy commented Jul 13, 2014

Okay, I appreciate you taking a look.

@mdo mdo mentioned this issue Aug 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants