473,503 Members | 10,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Answer to disabling text selection using CSS

10 New Member
I've read two threads that have been closed in which a user posed the question,

"Can I disable text selection using CSS?"

The responses were either hopeless or critical of the inquirer. I thought it'd be a nice gesture to answer the question with what was expected as well as some pointers regarding the topic.

Answer: YES.
An article posted some time ago describes the process of overriding the default selection color employed by browsers. This property is accessible through CSS.

Code:
Expand|Select|Wrap|Line Numbers
  1. ::selection {
  2.     background: none; /* Safari */
  3.     }
  4. ::-moz-selection {
  5.     background: none; /* Firefox */
  6. }
The article where I found this can be read here:
http://css-tricks.com/overriding-the...olor-with-css/

Although the article describes changing the color of the selection box, we can simulate a disabled selection by changing the background property to "none".

PROS: Your desired result is achieved.
CONS: Limited support across all browsers; not a truly disabled selection.

I'll add that the referenced site, css-tricks.com, is an excellent source for these types of questions. Additionally, visit smashingmagazine.com for articles that cover the latest web technologies and tricks being used by developers.

Hope this helps!
Mar 10 '10 #1
1 2091
rbuczynski
10 New Member
*note to admin*
I've posted this thread in the JavaScript forum because this is where the original questions appeared.

Please move thread to HTML/CSS if necessary!
Mar 10 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
3466
by: Ed Suominen | last post by:
I'm thinking of implementing a real-time collaborative text editor in Python using Twisted. An initial plan is to use a Twisted PB server daemon that accepts user:password:file connections from...
1
1698
by: Fawke101 | last post by:
Hi there, I have a .asp page that has a text box and a list box. The user enters criteria into ONE of the boxes. What i would like is that when the user makes a selection from the list box...
5
3269
by: nboutelier | last post by:
Scenario: you enter "foo bar" into a text field... Is it possible through javascript to select/highlight just "foo"? formObject.select() selects all. I need to select only part of the string....
6
2541
by: sonic | last post by:
Hi, I am experimenting with different viewstate management ideas for large datagrids, and found a microsoft suggestion to turn it off, and only store relevant information by manually accessing...
1
2070
by: Loui Mercieca | last post by:
Hi, Is there to disable or hide a listitem in a dropdownlist? Thanks
1
1761
by: Jay Why | last post by:
I'm working on some drag-n-drop javascript code for a web app, where the company requires all the users to be on Win XP, using IE 6 (so I don't care about cross-browser compatibility - lucky me!) ...
2
4274
by: ahynes | last post by:
HI folks, I'm a chem engineer with no VB programming knowledge (as you'll see from my question!) I want a script to open a .txt file, insert pre-defined text into the start and end of the...
2
19703
by: ahynes | last post by:
HI folks, I need a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this so I can run it...
9
6413
by: dozingquinn | last post by:
Hello, I have a combo box on a form that I would like to 'lock' the selection of after the user makes a selection, then either moves to the next record or saves the form. This selection will...
3
4985
by: brat33 | last post by:
I am trying to use a command button to automate a process for creating mailing labels from a query in Access 2007, going into word 2007. Current code looks like the following: 'Start MS Word Dim...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.