tags:

views:

67

answers:

2

In a normal textbox created in Rails by:

<%= text_area_tag 'chat_data', '', :rows => 30, :cols => 70 %>

is it possible to have fonts for the text, such as bolding and colouring? I'm using the textbox to store a chat session and want to make it more aesthetically pleasing.

+3  A: 

No, that's not possible. WYSIWYG editors in HTML use a nifty trick involving an editable attributed element, not a textarea.

Konrad Rudolph
+5  A: 

I would forget <textarea>s completely. Output HTML into a <div> and use CSS to format your markup.

An example:

<div class="chatbox">
    <p><span class="name">Oli:</span> My message</p>
    <p><span class="name">Oli:</span> My message</p>
    <p><span class="name">Oli:</span> My message</p>
    <p><span class="name">Oli:</span> My message</p>
</div>

with some of the following formatting:

.chatbox {overflow:auto;width:500px;height:200px}
.chatbox p {}
.chatbox .name {font-weight:bold}

All fairly simple but you can dial it up if you know how. (Note: width and height must be fixed for overflow to work).

Oli
And how would I get a scrollable text area?
alamodey
That's the div. Give it overflow:auto and you'll have a scroll-bar when it's got too much content. You certainly need to know a bit of CSS but that's true with either route.
Oli
Why are there two <span>'s and just one </span>?
alamodey
My bad. *edits* I was going to go for two spans per paragraph but realised it probably wasn't necessary.
Oli