# Unwanted line break

**URL:** <https://www.ruby-forum.com/t/unwanted-line-break/177783>\
**Category:** Rails\
**Created:** [October 23, 2009, 5:30pm UTC](https://www.ruby-forum.com/t/unwanted-line-break/177783 "2009-10-23T17:30:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [October 23, 2009, 5:30pm UTC](https://www.ruby-forum.com/t/unwanted-line-break/177783/1 "2009-10-23T17:30:19Z")

</div>

In using form helpers, where I specify:

\<%= f.label “Amount $” %\>  
\<%= f.text\_field :amount %\>

I get a line break between the label and the text field. How do I  
precent that? Thanks, Rvince

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [October 23, 2009, 5:37pm UTC](https://www.ruby-forum.com/t/unwanted-line-break/177783/2 "2009-10-23T17:37:56Z")

</div>

Use “-” at the end of the code in the view, like this:  
\<%= f.label “Amount $” -%\>  
\<%= f.text\_field :amount -%\>

* * *

```
    Agustin ViÃ±ao

```

www.agustinvinao.com.ar  
agustinvinao (Skype)

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [October 23, 2009, 10:21pm UTC](https://www.ruby-forum.com/t/unwanted-line-break/177783/3 "2009-10-23T22:21:13Z")

</div>

RVince wrote:

> I get a line break between the label and the text field. How do I  
> precent that?
> 
> Agustin ViÃ±ao wrote:
> 
> > Use “-” at the end of the code in the view, like this:  
> > \<%= f.label “Amount $” -%\>  
> > \<%= f.text\_field :amount -%\>
> > 
> > * * *
> > 
> > ```
> > Agustin ViÃ±ao
> > 
> > ```
> > 
> > www.agustinvinao.com.ar  
> > agustinvinao (Skype)

Wait… Do you mean that you’re getting a unwanted line break in the  
HTML source, or on the rendered web page? \<%= -%\> will prevent line  
break characters in the underlying HTML source code, but that line break  
character should not generate a new line in the rendered HTML. That  
should require a   
 tag.

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [October 23, 2009, 10:30pm UTC](https://www.ruby-forum.com/t/unwanted-line-break/177783/4 "2009-10-23T22:30:05Z")

</div>

On Fri, Oct 23, 2009 at 1:21 PM, Robert W.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > \<%= f.label “Amount $” -%\>  
> > > \<%= f.text\_field :amount -%\>

> Wait… Do you mean that you’re getting a unwanted line break in the  
> HTML source, or on the rendered web page? \<%= -%\> will prevent line  
> break characters in the underlying HTML source code, but that line break  
> character should not generate a new line in the rendered HTML. That  
> should require a   
> tag.

…or the LABEL or TEXTAREA (or both) being declared as a block  
element in the CSS.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [October 23, 2009, 10:50pm UTC](https://www.ruby-forum.com/t/unwanted-line-break/177783/5 "2009-10-23T22:50:12Z")

</div>

Robert W. wrote:  
[…]

> Wait… Do you mean that you’re getting a unwanted line break in the  
> HTML source, or on the rendered web page? \<%= -%\> will prevent line  
> break characters in the underlying HTML source code, but that line break  
> character should not generate a new line in the rendered HTML. That  
> should require a   
> tag.

Small nitpick: in the rendered HTML, you’d actually need a   
 tag.  
  
 is XHTML syntax, and is not actually valid HTML 4.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
