The placeholder's line height within the input field is refusing to budge to the top

Despite my efforts to adjust line-height, browser compatibility, padding, and vertical-align, the placeholder text remains stuck in the center of the input box. Any recommendations for fixing this issue?

I ran some tests on jsfiddle to rule out any issues with my CSS file, but unfortunately, the problem persists.

Check it out here

#postdoc {
   background-color: gray;
   width: 780px;
   height: 500px;
   margin-right: auto;
   margin-left: auto;
   border: 1px solid black;
   margin-top: 30px;
   margin-left: 30px;
   padding-top: 30px;
   float: right;
 }
 #postdoc label {
   float: left;
   width: 200px;
   text-align: right;
   margin-right: 10px;
   padding-left: 10px;
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
   -o-text-overflow: ellipsis;
   font-size: 25px;
   margin-bottom: 30px;
   margin-left: 20px;
 }
 #postdoc input[type="text"] {
   margin-bottom: 30px;
   height: 300px;
   width: 500px;
   font-size: 20px;
   margin-left: 10px;
   box-shadow: 0 0 5px black;
   vertical-align: top;
   
 }
 #postdoc input[type="file"] {
   margin-bottom: 30px;
   height: 50px;
   width: 500px;
   font-size: 20px;
   margin-left: 10px;
   box-shadow: 0 0 5px black
 }
 #postdoc input[type="submit"] {
   margin-bottom: 30px;
   height: 45px;
   width: 250px;
   font-size: 30px;
   margin-right: 100px;
   float: right;
   background-color: #4EA24E;
   color: blue;
   border-radius: 5px;
   text-shadow: 0 0 10px yellow;
   box-shadow: 0 0 10px black;
   font-family: Rockwell, 'Courier Bold', serif;
 }
 #postdoc input[type="submit"]:hover {
   color: gold;
 }
<!DOCTYPE html>

<html>


<head>
  <link rel="stylesheet" href="prostylesheet.css" type="text/css">

  <meta http-equiv="X-UA-Compatible" content="IE=80" />
</head>


<body>
  <h1 class="name"><font color = "#3399FF"> Prog-Assist |  </font><font size = "12" font color = "#4EA24E"> Programs Deployed</font></h1>

  <div id="header">
    <div id="gradient">
      <div class="nav">

        <!-- container-fluid gives full width container of whole viewport -->

        <div class="container-fluid">


          <ul id="nav1" class="text-left">
            <li><a href="main.html"><strong>Home</a>
            </li>
            <li><a href="tech.html">Technologies</a>
            </li>
            <li><a href="programsPage.html">Programs</a>
            </li>
            <li><a href="#">Blog</strong></a>
            </li>
          </ul>

          <ul id="nav2" class="text-right">
            <li><a href="#"><strong>Sign In</a>
            </li>
            <li><a href="#">Contact</strong></a>
            </li>
          </ul>

        </div>
        <!-- end container-fluid-->

      </div>
      <!--end nav-->
    </div>
  </div>
  <!-- end header -->


  <form id="postdoc" action="upload.php" method="POST" enctype="multipart/form-data">

    <label>Comment:</label>
    <input type="text" name="comment" placeholder="Comments">
    <br>

    <label>Text Document:</label>
    <input type="file" name="documentfile" />
    <br>

    <input type="submit" name="submit" value="Post comment" class="button">

  </form>


</body>

</html>

Answer №1

In situations where you need to input multiple lines of text, it is recommended to utilize a textarea:

<textarea style="height: 500px; width: 100%;">
Additional notes
</textarea>

Keep in mind that the input element is only suitable for single-line inputs.

Answer №2

It's hard to pinpoint the exact reason for this. One possible explanation could be that the height is evenly distributed from top to bottom, causing the text to appear in the middle. A better solution might be to utilize padding instead:

#postdoc input[type="text"] {
   margin-bottom: 30px;
   /*height: 300px*/  //commented out
   width: 500px;
   font-size: 20px;
   margin-left: 10px;
   box-shadow: 0 0 5px black;
   padding: 0 0 50px; //added
}

FIDDLE

If you're not concerned about aesthetics and need a user to enter a block of text, consider using

<textarea></textarea>
instead of <input/>.

Answer №3

Consider using a textarea element instead of an input.

Check out this example:

<textarea name="comment" placeholder="Comments"></textarea>

http://jsfiddle.net/r5t7nky3/8/

If you want to style the placeholder text, you can use the following CSS code:

::-webkit-input-placeholder { /* WebKit browsers */
  color: blue;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
  color: blue;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
  color: blue;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
  color: blue;
}

Keep in mind that this styling may only work on newer browsers.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Try utilizing the adjacency selector in Less again

Is it feasible to repeat this pattern an unlimited number of times using Less with the provided CSS selectors? I've been looking into using loops, however, I haven't come across any examples that achieve a similar result. .page-section { ba ...

The display of data attributes is not being rendered correctly

Check out the fiddle I'm currently working on: http://jsfiddle.net/7Z8wY/9/ The HTML section looks like this: <div class="container"> <div class="right"> <div id="cityList" class="inner-table"></div> </div> ...

Replace minor components (SVG) within the primary SVG illustration

I'm interested in transforming SVG elements into the main SVG element. For example, let's say the black square represents the main SVG element. I want to change elements 1, 2, and 3 to different SVG elements using JavaScript code. However, I am u ...

unable to scroll to the bottom of a div after receiving new data through ajax requests

I'm having an issue with a div that has a scrollbar. Initially, the div scrolls to the bottom when loaded. However, after making a post request and loading new ajax data, it no longer scrolls to the bottom properly. It seems to be going to the "previo ...

Implementing a PHP function to retrieve rating values when clicking on star icons

I am looking to implement a star rating system for users and update the database values accordingly after each rating. Below is my PHP code snippet: <?php foreach($genres as $genre){ $jsqla = mysql_query("select id,name,rate_score,rate_number,vide ...

Interactive Gridview feature enables users to rearrange data elements easily by dragging and dropping them into desired

Currently, I am working on a sample project involving the drag and drop functionality of a grid view that allows users to reorder data. My main challenge is figuring out how to retrieve the data from the first column in the order that the user has changed ...

Display a toggle button to show or hide a particular div when looping through a MySQL fetch

I wrote a function that toggles the display of a button when it's pressed: <script language="javascript"> function toggleButton() { var btn = document.getElementById("toggleBtn"); if (btn.style.display === "none") { btn.style ...

Tips for implementing this code for effective DAO and CRUD operations

As I venture into coding CRUD operations for the first time, I encountered an issue while testing the update functionality: The error message "Dao.get() missing 1 required positional argument: 'id'" is puzzling me. Where could I have gone wrong? ...

javascript: window.open()

I am currently using VB.NET 2005 and I have a requirement to launch a new browser window using Process.Start(). The challenge is that I need to specify the size of the browser window, for example, height:300 and width:500. Process.Start("firefox.exe", "ab ...

Which is more recommended to use in AJAX (XMLHttpRequest) - eventListener or readyStateChange method?

As I revisited a video from WWDC12 discussing advanced effects with HTML5, I couldn't help but notice that for the demo they utilized req.addEventListener("load",callback,true) instead of the usual onreadystatechange. This made me wonder: what differ ...

Is it possible to use jQuery to dynamically reset values?

I am currently working on paginating a section. The pagination is functioning properly, but I would like to know if it is possible to reset the pagination dynamically based on the number received from an input using jQuery. For example: In my current pa ...

Rotating Images with CSS Transitions

Is there a way to rotate an image 90 degrees on click and then back to 0 degrees with another click, using only CSS? I found a solution with jQuery on this website, but I'm looking for a pure CSS alternative. ...

New Feature in Bootstrap 4 Beta: Double dropdown icons now available in Options Menu

I'm facing an issue with the way Bootstrap is displaying my options menu. Here's a screenshot for reference: https://i.sstatic.net/LLxcF.png I'm unsure of what's causing this problem. I've omitted labels in this case, but they do ...

Exploring the Differences Between Nth-CSS and Jquery

What are the advantages of using the nth function in CSS instead of applying it through jQuery, especially considering its compatibility with IE? Is it better to simply use jQuery from the start and avoid using it in a stylesheet altogether? Hopefully thi ...

The null space vanished between the spans following the enhancement of libraries

Recently, I updated my Angular libraries from version 11 to 15 and also upgraded various REST libraries such as Bootstrap and ngxBootstrap to their latest versions. However, after performing these updates, I noticed that there was a loss of empty space bet ...

What is the best way to spin an element around its center?

I'm faced with a challenge where I have an element that needs to be rotated using JavaScript. The rotation is currently functional, but it's rotating around points other than its center. My goal is to rotate the element around its own center. ...

Create dynamic div animations triggered by changes in size of another div

Struggling to get this animation to function correctly. I have a vertical scrolling page with various sized div elements that change based on the content. The problem is that when these size changes occur, the other elements are moving abruptly. I want to ...

Create two div elements that dynamically overlap two additional div elements on a responsive layout

https://i.sstatic.net/hdcKn.png I'm really intrigued by the idea of making divs overlap each other in a unique way. I wonder if it's possible and if there are techniques to make this responsive using Bootstrap or another library. Could the divs a ...

Angular show more button determined by line count, not letter count

I am looking for a solution in Angular or CSS that will automatically add a "read more" button if the text is longer than 5 lines. My Angular page currently limits text to 150 characters. {{post.post_text | limitTo:letterLimit}} However, some posts are ...

Showing data from a MySql database using an HTML table

I am currently working on a pop-up form that captures user data and stores it in a MySQL phpmyadmin table. My goal is to have this data displayed in an HTML table once the popup form is closed. After submitting the form, I am redirected back to the homepag ...