Seeking ways to activate child input text selection in Mozilla Firefox through CSS?

Imagine this scenario: I have a webpage where all elements that are displayed must not be selectable.

<html>
<head>
    <style type="text/css">
        body {
            -webkit-user-select: none;
            -moz-user-select: none;
        }
        div {
            border: solid 1px green;
            padding: 5px;
        }
    </style>
</head>
<body>
    <div>
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
        nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
        suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
        vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat
    </div>
    <div>
        <input type="text" value="You can select the text from me" />
        <textarea>
            And me too.
        </textarea>
    </div>
</body>
</html>

In Google Chrome, you can still select text within input and textarea, but not in Firefox. I've attempted to override this behavior with CSS using:

input, textarea {
    -moz-user-select: text !important;
}

However, this does not seem to work because these tags are nested in a document body element that is already non-selectable. Is there a way to allow text selection within these nested user input elements in Firefox through CSS?

I appreciate any insights or suggestions you may have.

Answer №1

Is this CSS code effective?

    body {
        -webkit-user-select: none;
        -moz-user-select: -moz-none; /* modified to -moz-none */
    }
    input, textarea {
        -moz-user-select: text;
    }

Does it work as expected?

For more information, visit this page.

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

Adjust the size of a div using absolute positioning

Can a div with absolute position be resized? I need this pink modal to maintain the same width as the input and resize accordingly. This modal will be utilized in a dropdown component, so it should resize along with the input. Moreover, is using absolute ...

Tips For Making Your Bootstrap 4 Page Fit Perfectly on Mobile Screens

Currently in the process of developing . The frontpage has been created and tested using Chrome's dev console's device toolbar. Ensured that the correct viewport is set and utilized Bootstrap's column system for stacking elements. However, ...

What is the best way to trigger an event function again once a specific condition has been satisfied?

I'm currently working on a project where I need a sidebar to scroll at a slower rate until it reaches a specific point, and then stop scrolling once that point is reached. Below is the jQuery code I've been using: $(window).on("scroll", function ...

What is the best way to load content into Bootstrap tabs?

I would like to incorporate a loading spinner within the bootstrap tabs. When a user clicks on a tab pane link, a loading spinner will be displayed for a few seconds before showing the actual tab content. HTML : <ul class="nav nav-tabs" id=&q ...

How to customize TextField error color in Material-UI using conditional logic in React

Currently, I am incorporating the React Material-UI library into my project and faced with a challenge of conditionally changing the error color of a TextField. My goal is to alter the color of the helper text, border, text, and required marker to yellow ...

Enhance the appearance of the standard black rectangle displaying the messages "No video source" or "No video permissions"

Is there a way to change the styling of the video element that appears as a black rectangle with a strikethrough play button when the user is prompted for permission on Safari? Does it have a specific ID, class, or tag that can be targeted? I'm curre ...

Adapting JavaScript functions from IE to work on Firefox and Chrome: A comprehensive guide

I have encountered an issue with a function that retrieves the selected text range within a contenteditable div. While it works perfectly fine in Internet Explorer, it doesn't seem to work in Firefox and Chrome. Could someone kindly provide guidance ...

Fixed Sidebar Position Changes when Bootstrap Modal Closes

We are facing a peculiar issue in our React application involving a sidebar and a bootstrap modal. The problem arises when we click the "X" button in the modal, causing the sidebar to momentarily drop down the page before the modal closes. This strange be ...

Height-based responsive navigation bar

I recently implemented a menu on my responsive website that appears when the viewport is 714px width or less. Upon clicking the button, a side-sliding menu emerges across the page. However, I'm facing an issue with setting the menu height to match th ...

Troubleshooting an Issue with CSS Sliding Doors

I'm having trouble getting the right image to show on my website. The left side of the image is fine, but I can't figure out how to make the right one appear. As a HTML/CSS beginner, I'm still learning the basics. For more information, vis ...

"The CSS problem is that the input tags should be aligned in the same row instead of the second row

If you could take a look at this jsfiddle example Currently, I am using bootstrap tags for my system. However, when I add more than 6 or 7 input tags, they spill over into a second row. I want them to all fit within the first row, similar to the image sho ...

The content is unclipped with a border-radius and hidden overflow

As I work on incorporating stylistic text inside rounded divs, I encounter a challenge where the text touches the top of the container. While I have successfully managed to customize various content elements such as nested divs and background images, this ...

Steps for adding a delete icon to a text input field and enabling the functionality to delete text

In the code snippet below, I am creating a text input field: <input type="text" class="signup-input text-value" name="" placeholder="e.g. <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d48554c405d41486d">[email pro ...

Designing php/mysql data in a container

After successfully converting an ordered list output into a div output, I now face the challenge of stacking arrays on top of each other (and side by side with the two divs) like they would in an ordered list. Here is the original code snippet: <?php ...

What is the proper location to insert CSS within Laravel?

What is the recommended location for storing CSS or JS files in Laravel? More specifically, what are the differences between placing CSS files in /public versus /resources/css? Which directory is preferable for storing my CSS files? ...

The styles from the base.css file are not being implemented in the Django project

I currently have a folder structure that looks like this: https://i.sstatic.net/a4nYD.png My goal is to import base.css into base.html so that it is applied globally: Here is my HTML: <!DOCTYPE html> {% load static %} <html> <head> ...

How can you adjust a background image to perfectly fit across various screen sizes?

I am just starting out with web development and I am building a website using HTML/CSS. The background of my site looks good on my macbook pro, but when I try to view it on a larger screen, the background repeats and the content stays in the top left corne ...

Displaying content conditionally - reveal a div based on user selection

I have a dropdown menu and need to determine whether to display a specific div using the value selected via v-if. <select class="custom-select custom-select-sm" id="lang"> <option value="1">English</option> <option value="2">Sv ...

Changes made to the _layout file in a cshtml project will not be visible in the files that inherit from it unless they are in

My Asp.net (cshtml) application consists of multiple modules stored in different directories. There is a shared directory that contains both the _layout and CSS files. Strangely, when I reference this layout file in other files that inherit from it, the CS ...

Creating a custom filter

I am working on creating a filter and I could use some assistance with making minimal changes to my code. I am confident that there is a practical solution for what I am trying to achieve and would appreciate any corrections or suggestions. Button01' ...