HTML - What is the element to display the text?

I am running a small chat application where I receive messages from the server that I would like to show to the user. Since I am more of a backend guy and lack experience in interface design, I don't know which element is best for displaying text.

I get two options:

  • Using a simple div

  • Using textarea

    (as far as I understand this is for input).

(It would also be nice if I could somehow disappear into the text using JQuery).

+3


source to share


3 answers


  • For readonly messages, it is better to use <div>

  • otherwise use <textarea>

    \ textbox ( <input type="text"...>

    ).

Fading is simple if the id of the element is foo

:



$('#foo').fadeIn();

      

+4


source


Use a tag for content and with Jquery you can add a range or a new paragraph tag for every new post:

<div id="chatContent">

</div> 

      



Then in JQuery you can do:

function chatMessageRecieved(message) {
   $("#chatContent").append("<p> " + messsage + "</p>")
}

      

+2


source


You have to use div, textarea is efficient for input

For jquery: http://api.jquery.com/fadeTo/

Example:

$('#div').fadeTo('slow', 1);

      

+1


source







All Articles