Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I make use of `::selection` for <input> in chrome browsers?
    primarykey
    data
    text
    <p>I am trying to set a background and color for Input values. I succeeded doing that <code>::-moz-selection</code> for Mozilla browsers, but <code>::selection</code> in Chrome and other browsers like Opera doesn't work.</p> <p>Screenshot of the form in Chrome- <code>::selection</code>. It <strong>fails</strong>: </p> <p><img src="https://i.stack.imgur.com/gcrRo.png" alt="Doesn&#39;t work in Chrome"></p> <p>Screenshot of the form in Mozilla Firefox- <code>::-moz-selection</code>. It <strong>works</strong>:</p> <p><img src="https://i.stack.imgur.com/tkty8.png" alt="Works fine in Mozilla Firefox"></p> <p>Here is my code:</p> <pre><code>&lt;form&gt; First name: &lt;input type="text" name="FirstName" value="John"&gt;&lt;br&gt; Last name: &lt;input type="text" name="LastName" value="Doe"&gt;&lt;br&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; &lt;p&gt;Your first and last name, please!!!.&lt;/p&gt; </code></pre> <p>And the CSS:</p> <pre><code>::selection { color: #fff; background: green; } ::-moz-selection { color: #fff; background: green; } input::selection { color: #fff; background: purple; } input::-moz-selection { color: #fff; background: purple; } </code></pre> <p>Could any one tell me how to make that work with Chrome and other browsers? Created a fiddle with the entire code <a href="http://jsfiddle.net/sjeev/aRKLC/5/" rel="nofollow noreferrer">here</a>.</p> <p><strong>Update</strong>: I would like to clear myself that the question is about adding <code>::selection</code> for the text inside <code>&lt;input&gt;</code> and other form fields(explained in the question at first place). The question is not about <code>::selection</code> for normal text in browsers other than Firefox(works fine in Firefox). I never had problems adding <code>::selection</code> for non-form elements in any browser.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload