Input element is not receiving the intended CSS styling

It's strange, I can't seem to identify the issue even though I have experience with CSS.

input {
  border: solid 1px #0066FF;
}
.docDataEditorRow input {
  width: 100px;
  font-size: 10px;
}

Here is the HTML:

<div id="docDataEditor">
    <form>
        <div class="column-50">
        <div class="docDataEditorRow">
            <label for="keyword-Fecha">Fecha</label>
            <input type="text" value="20131122" id="keyword-Fecha">
        </div>
        <div class="docDataEditorRow">
            <label for="keyword-Fecha de Creacion">Fecha de Creacion</label>
            <input type="text" value="2013-11-22 00:00:00" id="keyword-Fecha de Creacion">
        </div>      
        </div>
 <div class="column-50"></div>
    </form>
  </div>

However, only the styles in the first input class are being applied.

The issue lies in this part of the code:

.docDataEditorRow input {
  width: 100px;
  font-size: 10px;
}

It doesn't appear to be getting applied or showing up as overridden in Firebug.

Answer №1

Issue Resolved

After examining the Fiddle, it was discovered that an invalid character in the CSS was causing a break and preventing styles from being applied.

Once the problematic character was removed, the styles were applied correctly.

Updated Fiddle Link


Suggested Solution

To avoid such issues, it is recommended to use class names instead of specific elements like input.

<input class="bacon" type="text" value="20131122" id="keyword-Fecha">

.bacon {
  width: 100px;
  font-size: 10px;
}

Using overly specific selectors like .docDataEditorRow input can lead to maintenance problems in the future. Keeping your CSS classes simple and generic is often the best approach for long-term maintainability.

Answer №2

There might be a conflicting rule overriding it. Have you checked the element inspector for the rule?

You could attempt this solution:

#docDataEditor .docDataEditorRow input[type="text] {
  width: 100px;
  font-size: 10px;
}

Answer №3

Check out this fiddle for reference: http://jsfiddle.net/DKJFp/

The code you provided seems to be correct as per your question, and it appears to be functioning properly...

Possibly there might be another issue in your code causing the problem.

input {
  border: solid 1px #0066FF;
}
.docDataEditorRow input {
  width: 100px;
  font-size: 10px;
}

<div id="docDataEditor">
    <form>
        <div class="column-50">
        <div class="docDataEditorRow">
            <label for="keyword-Fecha">Fecha</label>
            <input type="text" value="20131122" id="keyword-Fecha">
        </div>
        <div class="docDataEditorRow">
            <label for="keyword-Fecha de Creacion">Fecha de Creacion</label>
            <input type="text" value="2013-11-22 00:00:00" id="keyword-Fecha de Creacion">
        </div>      
        </div>
 <div class="column-50"></div>
    </form>
  </div>

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

Node.js and MongoDB Login Form Integration with Mongoose

I am relatively new to web development and currently working on a simple web page for user login authentication. My goal is to verify user credentials (username & password) on the LoginPage from a mongoose database, and if they are correct, redirect them t ...

What is causing the input boxes to exceed their container boundaries so drastically?

My plan was to organize 4 input text boxes in 4 equal columns on a single row of the form. Using Bootstrap's grid column classes, I set col--3 for medium and large screens for those four inputs. For small and extra-small sizes, I designated them as co ...

Aligning content within a div block

I created a div block that houses a form structured like this: <div class="divClass"> <form id="frm" method="post" action="/NotDefinedYet/index.xhtml" class="frmClass"> <input type="text" name="j_idt9:j_idt10:Username" placehold ...

Having trouble aligning Bootstrap SVG icons to the center

I'm struggling with getting the svg icons centered on my welcome.blade.php file. Instead, they appear shifted to the right. I would really appreciate any help or advice on how to fix this issue. Check out a screenshot here My welcome.blade.php code s ...

Is there a way to access specific methods within a JavaScript file?

Within my javascript assets folder, I have a file named jstester.js that looks like this: function hehe() { alert("wedsdsd"); } document.write("fdygsdfysdgf"); Then in the main index.html file in the public directory, I include the following code: & ...

I am in search of a clean and efficient method to modify the class of a link that triggers an HTMX request in Django. Perhaps something like "auto-refresh" or a similar solution would be ideal

I've encountered an issue with HTMX in Django. The page consists of two main components: a list of categories and the content that is displayed when a category is clicked. Initially, everything was working smoothly with standard htmx functionality. H ...

Shuffle contents of a Div randomly

I'm currently in the process of developing a new website and I need to randomly move the news feed. To achieve this, I have created an array containing the list of news items. The array is then shuffled and placed within the news feed section. Althou ...

I noticed that my jquery code is injecting extra white space into my HTML5 video

Ensuring my HTML5 background video stays centred, full-screen, and aligned properly has been made possible with this jQuery snippet. $(document).ready(function() { var $win = $(window), $video = $('#full-video'), $videoWrapper = $video. ...

Is there any benefit to making the SVG elements width and height 100%?

The Angular Material documentation app features an SVG Viewer that is able to scale the SVG content to fit the container using the following function: inlineSvgContent(template) { this.elementRef.nativeElement.innerHTML = template; if (this.sca ...

What methods can I use to eliminate an iframe virus that has infected all my PHP files on my website?

I'm facing a challenge with eliminating a virus code from my php files. All 1200+ php files on my server have been infected by this malicious code, which injects the following line into the html output: Here is the virus code: <tag5479347351>& ...

Executing a Parent Page JavaScript Method from Within an iFrame

I have included an iFrame in my application. To illustrate, consider the following example: The main page contains <html> <head> <script src='jquery.js'></script> <script> function TestFunction() ...

Strange arrangement of items in navbar - Using BOOTSTRAP 4

I'm currently experimenting with BOOTSTRAP 4 and the navbar, but the output on my webpage doesn't match what I want to achieve. https://i.sstatic.net/FnGlv.png What I want to achieve is shown in the following link: https://i.sstatic.net/oelsv. ...

Tips for enhancing the responsiveness of a calendar table in Bootstrap 5.2

Hello there! I need some help with adding rounded borders to tables using Bootstrap. Can anyone assist me with this? I'd be truly grateful for any guidance on this matter. Unfortunately, Stack Overflow is not allowing me to post my question, so I&apos ...

Adjust the <div> element to dynamically resize based on the user's browser changes

I need a div to adjust its width and height dynamically based on the browser dimensions when a user resizes their browser window. Implemented code following the provided suggestions: <!DOCTYPE html> <html> <head> <link rel="s ...

What steps are necessary to facilitate payments through Stripe instead of directly on my Wordpress website?

On my Wordpress website, I have created a page where users can select a subscription offer. Currently, the layout looks like this: https://i.sstatic.net/qltbU.png My goal is to redirect users to a Stripe payment page when they click on any of the subscrib ...

Enumerating multiple div elements in Selenium using Python

I am attempting to create a web scraper in Python, but the classes of the tiles are updated dynamically. This means my only option is to use xpaths. The issue I'm facing is that within the divs, they change between different cards. For example, Card ...

Utilizing HTML input elements for focus and blur events

I'm attempting to style an input text field with a thick blue border when in focus, and then have it revert back to its default border when no longer in focus. Here is how one of my input fields is currently defined: <input onfocus="this.style.bor ...

Is it possible to achieve complete separation of concerns when it comes to HTML, CSS, and JS?

What is the best way to achieve separation of concerns between HTML, CSS, and JS using this HTML structure? <nav role="navigation" class="site-nav js-site-nav"> <ul class="site-nav__list"> <li class="site-nav__item"><a href="#" ...

display complete map using full height in a bootstrap 4 row

Struggling to get the map in this column to fill the entire height within a Bootstrap4 column. After attempting to add h-100 to the row, scroll bars appeared at the bottom of the map and the bottom 10% of the page went missing. https://i.sstatic.net/epfx ...

What is the best way to display JSON responses from AJAX in separate divs with identical class names?

I've been going through a whirlwind of confusion lately, unable to find a solution after spending over 100 hours on this. I'm reaching out for help in hopes that someone can guide me in the right direction! UPDATE: To clarify my issue and seek a ...