Shahab Khan
Shahab Khan

Reputation: 1059

Is that possible to next line in Input tag in html css?

I have an input tag, when i am typing in input, after a given width the text is overflow hidden.. What actully i need is when I am typing in input the text goes to next line, Is that possible. only input not textarea.

    input {
        height: auto;
    
    }
<!DOCTYPE html>
<html>
<body>

<h1>The input element</h1>

<form action="/action_page.php">
  <input type="text"  id="comment" name="comment" /><br/>
  <input type="submit" value="Submit">
</form>

<p>Click the "Submit" button and the form-data will be sent to a page on the 
server called "action_page.php".</p>

</body>

</html>

Upvotes: 0

Views: 67

Answers (1)

allancoding
allancoding

Reputation: 549

autosize(document.getElementById("comment"));
#comment{
    resize: none;
    height: 16px;
}
<!DOCTYPE html>
<html>
<body>

<h1>The input element</h1>

<form action="/action_page.php">
  <textarea id="comment" name="comment"></textarea><br/>
  <input type="submit" value="Submit">
</form>

<p>Click the "Submit" button and the form-data will be sent to a page on the 
server called "action_page.php".</p>

</body>
<script src="https://rawgit.com/jackmoore/autosize/master/dist/autosize.min.js"></script>
</html>

Upvotes: 1

Related Questions