News for hackers. Stuff that matters.
Re:The Importance of Manually Breaking Lines of Text by LukeB_UK on Sunday October 19, 2014 @04:31PM (#8479505)
This is terrible advice and is a massive hack as well as being a terrible misuse of hr element.

Also I'm not sure I want to take advice on how to lay out my content from someone who claims to be a designer but has his content in such a limited space (less than 40% of my screen space on a 15 inch monitor) and all the way to the left.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @05:21PM (#8479661)
Text is easier to read when narrow. Agree on the centering.. working on some solutions for it. I only had ~1h to put into the site.
Re:The Importance of Manually Breaking Lines of Text by LukeB_UK on Sunday October 19, 2014 @05:47PM (#8479749)
Text is annoying to read when it's too narrow, yours is too narrow. Bumping it up from 500px to 800px makes it look less sparse and is still readable.

For the centering, margin: 0 auto; on .textWrapper is an improvement.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @05:54PM (#8479775)
Goes against the MD style of the homepage.. trying to find another solution.
Re:The Importance of Manually Breaking Lines of Text by LukeB_UK on Sunday October 19, 2014 @06:02PM (#8479802)
Making the content 800px wide and setting the margin the same way looked perfectly fine on both the blog post and the home page, much better than all the way to the left and smaller.
Re:The Importance of Manually Breaking Lines of Text by gwern on Sunday October 19, 2014 @05:39PM (#8479733)
> Text is easier to read when narrow.

Have you A/B tested that?

Re:The Importance of Manually Breaking Lines of Text by berzniz on Sunday October 19, 2014 @04:11PM (#8479447)
This is such a bad idea that I had to comment here:

1. Doesn't scale. You do not want to hand pick text all over your site/web-app. 2. It's not semantic. 3. It's very confusing to new people who looks at your code. 4. If you ever change a single char in that sentence, you will have to re-break it yourself.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @04:14PM (#8479458)
Thanks for commenting. It's a great idea from a design and readability perspective. It sounds like you do not like my implementation - you could be right. Here is another way of doing it.. maybe I'll update the post late:

<div class="desktop-breakline"></div>

with the appropriate @media query.

It's obviously not for every situation. But for landing and marketing pages, headlines, etc, I'd go as far as to say it's absolutely essential.

Re:The Importance of Manually Breaking Lines of Text by jrochkind1 on Sunday October 19, 2014 @05:08PM (#8479623)
I've also done simply:

<span class="line">First line</span> <span class="line">Second line</span>

Make em block level in css, collapsing to display:inline at small sizes. (Can even set the size with a specific class, bootstrap-style).

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @05:24PM (#8479667)
Yeah that works, but it creates a lot of code. <hr> is just 4 characters, and reminds me a lot of <br>, so its easy to read. Once you adapt your perspective to it, it becomes really awesome.
Re:The Importance of Manually Breaking Lines of Text by mariusc23 on Sunday October 19, 2014 @10:27PM (#8480476)
<hr> is a poor choice from an accessibility perspective. You should use a <span> instead.
Re:The Importance of Manually Breaking Lines of Text by recursive on Sunday October 19, 2014 @03:17PM (#8479225)
This really only seems to work if you know the exact pixel width of the text in question. This would happen if you don't know the font being rendered or actual text in advance, which are both common occurrences in web development.
Re:The Importance of Manually Breaking Lines of Text by jrochkind1 on Sunday October 19, 2014 @05:10PM (#8479632)
Nah, you just don't need to know the exact pixel width.

For this example, you just need to know that the full sentence is likely to break some place on a large screen, and that the half-sentences are likely to fit without breaking on certain size screens.

Maybe you need the boundaries of likely maximum and minimum pixel widths, you certainly don't need to know the exact pixel width.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @03:17PM (#8479231)
This is more of a finishing touch, rather than something you would do initially.
Re:The Importance of Manually Breaking Lines of Text by recursive on Sunday October 19, 2014 @03:22PM (#8479252)
I'm talking about a deployed production app also.

Css has font fall-backs for a reason, and if you ever use them, that means you don't know which font is actually being rendered. Which is not to mention platform differences for rendering even the same fonts.

And if any part of the text is variable, which is pretty much the basis for web apps, then you have another problem.

It would be pretty great if there was something like <wbr> that you could use for this scenario.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @03:27PM (#8479270)
Sure you can certainly run into that issue in some cases, that's where your judgement as a developer should kick in.
Re:The Importance of Manually Breaking Lines of Text by bshimmin on Sunday October 19, 2014 @03:33PM (#8479291)
Why not just use a BR and set its "display" to "none" at the appropriate breakpoint(s)? Why abuse HR in this way?
Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @03:36PM (#8479303)
You can't do display none for BR element. But even if you could, you wouldn't want to overwrite it for the entire website. Also, the HR element is a very old, largely unused, and styleable, so its a good candidate for this.
Re:The Importance of Manually Breaking Lines of Text by bshimmin on Sunday October 19, 2014 @03:42PM (#8479327)
"display: none;" works just fine for BRs!

Sure, you don't want to override it for the entire web site, but if you're being specific enough about showing/hiding line breaks at certain breakpoints, then I don't see why you can't just specify with the class of the container (or whatever) which particular BR you want to hide in a given context.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @04:00PM (#8479406)
You also may want the flexibility of both. For example:

<strong>Headline</strong><br> The quick brown fox jumped<hr> over the lazy dog.

And the code is clear and easy to read.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @03:48PM (#8479359)
Hmm.. good point, it wasn't working when I tried it. But I still prefer to include it on a high level into my CSS frameworks. Set it, forget it, and use freely.
Re:The Importance of Manually Breaking Lines of Text by bshimmin on Sunday October 19, 2014 @03:56PM (#8479391)
At least a few people on HN use Lynx - they won't like you much for this!
Re:The Importance of Manually Breaking Lines of Text by tobyhinloopen on Sunday October 19, 2014 @03:57PM (#8479397)
Why on earth would you use Lynx?
Re:The Importance of Manually Breaking Lines of Text by hobs on Sunday October 19, 2014 @04:08PM (#8479434)
Because you are blind?
Re:The Importance of Manually Breaking Lines of Text by DanBC on Sunday October 19, 2014 @05:19PM (#8479651)
Lynx and Dillo are very fast. Also lightweight.
Re:The Importance of Manually Breaking Lines of Text by tobyhinloopen on Sunday October 19, 2014 @03:56PM (#8479393)
<br class=hidden-for-mobile>

:D

Re:The Importance of Manually Breaking Lines of Text by gavinballard on Sunday October 19, 2014 @03:43PM (#8479336)
Not sure if "largely unused" is right. I use them all the time, and have seen them in pretty common use around the place.
Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @03:51PM (#8479366)
Ah, I think you are in a minority. Or maybe I'm very opinionated :)
Re:The Importance of Manually Breaking Lines of Text by err4nt on Sunday October 19, 2014 @05:00PM (#8479594)
This is a great technique and I've been using it on projects for over a year now. This is the first time I'm seeing anybody else write about it or use the technique!

One question for the author: Why repurpose a Horizontal Rule <hr> when HTML has a perfectly functional Line Break tag <br>?

You can use @media queries to set display: none; on <br> tags and then those <br> tags have no effect, and then you get to decide when they kick in.

This is a great idea, but ignoring the built-in line break to repurpose and restyle the horizontal rule tag seems like an arbitrary choice for implementing the technique.

Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @05:08PM (#8479627)
Thanks for the positive feedback! My reasons are: 1) You still want to have the option of a "hard" BR 2) I want to set the HR as a high level class, so I can use it freely through whatever I'm working on.

For example:

<strong>Headline</strong><br>

The quick brown fox jumped <hr>

over the lazy dog.

You 100% want the line break after the headline, and want to set an optional one in the subtext.

I like it because its very clean to look at, but you can also create a responsive class like <div class="desktop-breakline"></div>

Re:The Importance of Manually Breaking Lines of Text by ajanuary on Sunday October 19, 2014 @05:30PM (#8479697)
If you're going as verbose as using a class, just put the class on the br tag.

<strong>Headline</strong><br> The quick brown fox jumped <br class="soft"> over the lazy dog.

Re:The Importance of Manually Breaking Lines of Text by err4nt on Sunday October 19, 2014 @06:13PM (#8479831)
This is what I did originally, <br class=”desktop“>

But now I'd rather just use the media query to only affect the <br> inside of the H1 or other container where the line break appears.

Another consideration I didn't see in the article that I train the people updating the marketing copy: put your white space before the line break. When it's all inline it will display as one line, but you don't want to have a space after the line break at the start of the new line. programmers may be conscientious of where the white space is but its a real eye-opener for marketing-types who only pay attention to the content, not the space around it!

Re:The Importance of Manually Breaking Lines of Text by thomasahle on Monday October 20, 2014 @07:40AM (#8481591)
Sounds more like CSS needs a way to set Widows and Orphans control. Just like it has lacked hyphenation for quite a while. Does anyone know if such a thing has been discussed?
Re:The Importance of Manually Breaking Lines of Text by qrohlf on Sunday October 19, 2014 @04:54PM (#8479580)
This is a rehash of a much more fleshed-out idea from here: http://blogs.adobe.com/webplatform/2013/01/30/balancing-text...

They even wrote a jQuery plugin to implement the described behavior: https://github.com/adobe-webplatform/balance-text

Re:The Importance of Manually Breaking Lines of Text by afarrell on Sunday October 19, 2014 @04:43PM (#8479538)
"""

> This page cannot be displayed because your computer is currently

> offline

"It looks pretty ugly - I hope you can understand why." """

But its not. When I see that, my eye is immediately drawn to the word that is on its own: offline. And what is the most salient piece of info in that error message? The fact that my computer is offline.

Re:The Importance of Manually Breaking Lines of Text by melloclello on Sunday October 19, 2014 @05:05PM (#8479611)
Re:The Importance of Manually Breaking Lines of Text by DanBC on Sunday October 19, 2014 @05:17PM (#8479647)
http://m.imgur.com/LIbRZaR

The Importance of Manually Breaking Lines of

Text.

Re:The Importance of Manually Breaking Lines of Text by Pxtl on Sunday October 19, 2014 @05:04PM (#8479609)
If you need this level of control, use a PDF. This is not what html/css/javascript is for.
Re:The Importance of Manually Breaking Lines of Text by antman on Sunday October 19, 2014 @03:10PM (#8479197)
<hr /> for validity in both XHTML and HTML4
Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @03:11PM (#8479205)
Updated
Re:The Importance of Manually Breaking Lines of Text by tobyhinloopen on Sunday October 19, 2014 @03:55PM (#8479390)
Who uses XHTML or HTML4?
Re:The Importance of Manually Breaking Lines of Text by tobyhinloopen on Sunday October 19, 2014 @03:03PM (#8479158)
I like this idea, thanks.
Re:The Importance of Manually Breaking Lines of Text by maxsavin on Sunday October 19, 2014 @03:09PM (#8479189)
Welcome :)