When the type attribute is set to "password" in Textbox, the CSS

I am new to CSS and I'm currently working on styling my Login page. Everything works fine when I keep the code as it is, but I want to change the password input field type to "password" for security reasons. However, when I do this, the CSS styles are not being applied to the password textbox.

.content input[type=text], .content input[type=password] {
  height: 30px;
  border: 0;
  margin-top: 2.5vh;
  margin-left: 4.5vw;
  border-radius: 20px;
}

.content input[type=submit] {
  color: white;
  margin-left: 7vw;
  margin-top: 2vh;
  padding-bottom: 10px;
  padding-top: 10px;
  padding-left: 15px;
  padding-right: 15px;
  border-radius: 6px;
  border: 1px solid;
  background-color: black;
  justify-content: center;
}

.content input[placeholder] {
  font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
  border: 1px solid;
  padding-left: 1vw;
  font-size: 13px;
}
<div class="content">
  <h2>Sign In</h2>
  <input name="username" type="text" id="username" placeholder="Username" /><br />
  <input name="password" id="password" placeholder="Password" Type="password" /><br />
  <input type="submit" name="Submit" value="Submit" id="Submit" /><br />
</div>

Answer №1

Incorporate TextMode="Password" into the password field so that the input element is referenced as a password. Currently, only the id and placeholder have been provided.

<asp:TextBox ID="password" runat="server" TextMode="Password" />

Answer №2

Take a look at this greatly simplified code snippet that displays some unusual behavior:

input[type=text],
input[type=password] {
    height: 30px;
    border: 0;
    margin-top: 2.5vh;
    margin-left: 4.5vw;
    border-radius: 20px;
}
<input id="username" name="username" placeholder="Username" />
<input id="password" name="password" type="password" placeholder="Password" />

Check your CSS, specifically focusing on this line:

.content input[type=text], input[type=password]

When the input type is not explicitly set to text, there is no default styling applied. Additionally, the selector for password type is incorrect and should be .content input[type=password].

Consider this updated version, which provides styling for all inputs without a specified type using the selector input:not([type]):

input:not([type]),
input[type=text],
input[type=password] {
    height: 30px;
    border: 0;
    margin-top: 2.5vh;
    margin-left: 4.5vw;
    border-radius: 20px;
}
<input id="username" name="username" placeholder="Username" />
<input id="password" name="password" type="password" placeholder="Password" />

Alternatively, you can explicitly set the Username input to be of type text by adding it in your code like this:

<asp:TextBox type="text" ID="username" placeholder="Username" runat="server" ></asp:TextBox>

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

The significance of font weight is negligible when it comes to printing an HTML webpage

When writing HTML, I include elements like this: <strong>this is basketball</strong> <div>this is basketball</div> <div style="font-weight:700">this is basketball</div> Everything displays correctly in the bro ...

Numpad functionality in JQuery malfunctioning post-ajax request

Using the jQuery numpad plugin has been flawless until after an AJAX call. I have tried various functions like on('click') and others, but unfortunately, none of them worked as expected. Apologies for my poor English! You can find the extension l ...

Developing Form Validations in Bootstrap (no need for additional plugins)

I am in search of a simple solution for form input validations that doesn't require a full-fledged jQuery plugin. Specifically, I need to keep one input disabled until integers are entered into two other inputs. The following if-loop is my attempt to ...

While attempting to make my div responsive, it unexpectedly became stuck to the navbar

After successfully creating a website that works fine on desktop, I encountered an issue when viewing it on my phone. The main content section, which features jokes, gets scrolled up along with the navbar. I followed a tutorial on YouTube to make the navba ...

The elements at the bottom of the Google homepage do not stay in place when hovering

I'm facing an issue and seeking guidance on how to make the footer and 'Google in different languages' fixed when hovering over the buttons. I'm attempting to create this on my own without referencing the Google homepage code in Chrome ...

In Javascript, swap out a particular colored region in an image with a different image

I've been scouring the internet in search of a solution to my problem, but it seems like I might not be looking in the right places. Imagine this image below, how can I replace the blue area with an image uploaded by the user? I'm struggling to ...

Emphasize a specific portion of the text

While developing a project similar to Google Search using React.js and GoogleAPI, an issue arose. For instance, when searching "tea" on Google, the results display "Searches related to tea" at the bottom. The term "tea" appears in bold. How can this be imp ...

Swap out a web link for an embedded iframe

Currently working on updating internal links: <div class="activityinstance"> <a href="http://website.com/hvp/view.php?id=515512">activity</a> </div> The goal is to convert them into: <div class="activityinstance"> ...

Top method for stacking several divs in a vertical line

In search of the most effective method for organizing numerous dynamically generated divs (all with identical widths) in a vertical stack, two potential solutions have emerged: Utilize float:left... Implement an unordered list and enclose each div within ...

Retrieve information from a database based on user input keywords utilizing PHP and SQL

I have been exploring ways to allow users to enter keywords via HTML forms and then use this information to retrieve the relevant data from a database using PHP and SQL. So far, I have only been able to display data from the database using a static SQL qu ...

Alignment of paging numbers in a data table

I'm encountering an issue with aligning the paging numbers in datatables. Here's the code snippet: The table generated dynamically using the Datatables library includes pagination and search functionality. I've used CSS to customize the pag ...

Stop the div from expanding because of oversize text in Bootstrap

I have the following HTML source code for a Bootstrap card: <div class="card shadow-none card-fluid mb-3 mb-md-5"> <div class="row"> <div class="col-md-3 col-lg-3 mb-3 mb-sm-0"> <img class="img-fluid rounded" ...

Avoid conflicts by using a selector for styling in the jQuery plugin

I am a beginner to jQuery and recently created a plugin using jQuery UI widget factory. The plugin is functioning well, but I have been using inline styling which may become complex for larger files. For larger projects, I have the option to use classes. ...

Is there an easy method to verify if the local storage is devoid of any data?

Query is named aptly; seeking to verify in a conditional statement. ...

Modifying the Inactive Tab Color in Material UI

For my application, I have a specific requirement where the active tab needs to be styled in red and the inactive tab in blue. Here is how the styling is set up: newStyle: { backgroundColor: 'red', '&$selected': { b ...

Customizing browser titles for various article pages on Joomla 3.2 for improved SEO performance

Is there a way to incorporate unique browser titles for various article pages? Additionally, I am seeking guidance on how to integrate distinct meta tags for different pages within a Joomla website... ...

Obtaining <script> and <div> elements from Plotly with Python

Seeking advice on the best way to extract <script> and <div> tags from the HTML output generated by Plotly's offline client. Ideally looking for a built-in method, but open to creating a custom solution if needed. I have experience with B ...

The Bootstrap tooltip effectively fades away after displaying text, but it is not positioned correctly above the icon

Having some issues with my tooltip functionality. It seems to display the text on the left side and fades away upon mouseover, but it doesn't show up in a proper tooltip box over the icon as expected. I suspect that there might be a conflict between j ...

Using a CSS hack to create a border cutout

The Dilemma... I am attempting to position div elements over a border, while maintaining space on both sides of each div. Take a look at the scenario: Note the gaps surrounding the black divs. I am struggling to find a solution for this issue, aside fro ...

VS Code warning about unused CSS selectors in SvelteKit

Is there a way to get rid of the Unused CSS selector warning in VS Code? I keep getting this warning in all files where I use <style lang="scss">. While I'm aware that I don't use the .btn class in some components, I still want it ...