Com­ment and it renders as: Com­ment in Chr" /> Com­ment and it renders as: Com­ment in Chr" /> Com­ment and it renders as: Com­ment in Chr"/>

Why the word "Com­ment" is rendered as is in Chrome? No soft hyphen

492 Views Asked by At

I have an html snippet:

<label class="col-xs-2 col-lg-2 control-label" for="param_comment">Com&shy;ment</label>

and it renders as:

Com&shy;ment

in Chrome v.29

I expected:

Comment

What is wrong with the soft hyphen?

Update:

I meant:

<label class="col-xs-2 col-lg-2 control-label" for="param_comment">Com&shy;ment</label>

Update 2:

I think it was an SLIM fault: I had:

 = label_tag(:"param_comment", "Com&shy;ment", class: "control-label")

now changed to:

 = label_tag(:"param_comment", "Com&shy;ment".html_safe, class: "control-label")

So the .html_safe helps.

But is it possible to do the same without ruby code?

1

There are 1 best solutions below

3
Jukka K. Korpela On

The HTML snippet posted contains Com&amp;shy;ment, so it works as defined. Use Com&shy;ment instead (or enter the soft hyphen as a character, U+00AD: Com­ment).