Page 1 of 1

non-breaking spaces.

Posted: Fri Dec 14, 2018 1:11 pm
by RSteinwand
Hi Albert,

While converting an existing site that was previously managed by a CMS to static pages, I ran into this gem:

Code: Select all

<li>Print the online form and mail it to: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PO Box 123, City, State</li>
Considering this page was full of single non-breaking spaces between words where an actual space would work, and it had at least 30 of the little buggers, I was surprised to see no notice in CSS. In this case the NBS's were apparently used to break to a new line. It reminded me of word documents where the user would use lots of spaces to center or indent text.

What's your take on this? Do you just count the number and if it's more than you can count on one hand, display a notice about styling with css would be more efficient?

Non-breaking spaces (&nbsp;) should not be used to indent or center text?

Thanks!

Re: non-breaking spaces.

Posted: Sat Dec 15, 2018 12:37 am
by Albert Wiersch
Hi Rick,

CSS HTML Validator is more of a technical syntax checker than a bad style checker. It's really difficult to check for bad style (but where it is easy to do so sometimes CSS HTML Validator will generate a message).

My thought is that I wonder how common this actually is (I would think it's rather rare) and if it would be worth generating a "style" message for that would do more good than harm and that wouldn't be confusing.

Have you come across this before? I think it is rather rare....... but what exactly should be the criteria for a style message? Perhaps CSS HTML Validator could count the number of consecutive &nbsp; and space characters and generate a style warning message if the count is at least 3 and &nbsp; has been used 2 or more times?

Re: non-breaking spaces.

Posted: Sat Dec 15, 2018 1:01 pm
by Lou
Like legislating good taste. I don't think there is anything in the standards that would prevent this absurdity.

I don't see that the validator could find/catch/warn all examples of bad style. That would be a rabbit hole that could bloat the validator to something asymptotic to Windows. My 2¢

Re: non-breaking spaces.

Posted: Sat Dec 15, 2018 1:11 pm
by Albert Wiersch
Lou wrote: Sat Dec 15, 2018 1:01 pmLike legislating good taste. I don't think there is anything in the standards that would prevent this absurdity.
No... it's more of a "bad style" issue but it might cause accessibility issues if this type of "formatting" is used instead of proper formatting using proper HTML and CSS.
Lou wrote: Sat Dec 15, 2018 1:01 pmI don't see that the validator could find/catch/warn all examples of bad style. That would be a rabbit hole that could bloat the validator to something asymptotic to Windows. My 2¢
Yes, there is no way to warn about everything but when it's an issue that isn't too hard to detect and warn about, I don't mind making CSS HTML Validator generate a message about it. A user could always disable the message.

Re: non-breaking spaces.

Posted: Sat Dec 15, 2018 7:54 pm
by RSteinwand
Hi Albert,

For the most part, I code everything from scratch so with the except of a typo, most everything is to my standards. In this case, I inherited 500 pages of CMS so coded by people who don't know how to code, so I'm seeing weird stuff. From what I've seen, with the exception of the above snippet, I can search and replace all of it with a space and consider I removed a lot of bloat. Most of what I've seen so far (other pages) has been on either side of a link, which I doubt is really needed. For some reason, this page was full of it. I just mentioned it because I thought it was an easy thing to code and pointed out bad style. It's your call if you want to add it.

Re: non-breaking spaces.

Posted: Sun Dec 16, 2018 9:36 am
by Albert Wiersch
Hi Rick,

Thanks for the suggestion. I'll note this on my list but will consider it a low priority item compared to other items on the list. :)

Re: non-breaking spaces.

Posted: Sun Dec 16, 2018 9:37 am
by RSteinwand
Thanks Albert!