473,651 Members | 2,659 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 smashingmagazin e.com for articles that cover the latest web technologies and tricks being used by developers.

Hope this helps!
Mar 10 '10 #1
1 2098
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
3495
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 text editor clients to make changes to a specified file on the server, and have the text editor clients update their local copies of the file based on local user input or input entered from other users, relayed via the server. Jabber compatibility...
1
1706
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 (sql populated) the text box is disabled, and when a user enters a character into the text box, the list box is disabled (not including spaces) This is a bit cosmetic, but what is the best way of doing this? Some client
5
3279
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. -Nick
6
2546
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 viewstate. as per some helpful suggestins in MSDN "Common DataGrid Mistakes" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-commondatagridmistakes.asp they suggest disabling datagrid viewstate and adding...
1
2084
by: Loui Mercieca | last post by:
Hi, Is there to disable or hide a listitem in a dropdownlist? Thanks
1
1774
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!) I've got the d-n-d code working, and I found code to use to turn off text selection while an object is being moved (which was just plain ugly.) However, I can't figure out how to turn text selection back ON after the object is dropped. The code to...
2
4284
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 file, then close teh saved file with a .nc extension. I'd like to have this as a batch file or exe file which i can installt o run from my users desktops. I tried doing it in Word using macros and the FileDialog thingy to bring up dialogs for the...
2
19708
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 from my desktop. I tried doing it in Word using macros and the FileDialog thingy to bring up dialogs for the user to select his files but it would not save the modified file for me and I couldn;t figure how to get it outside of Word. Code below.
9
6427
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 therefore be unable to be changed afterwards. From my research, I'm assuming that the following code needs to be placed into form_current event somehow: Private Sub PHIconsultantcombo_LostFocus() PHIconsultantcombo.Locked = (PHIconsultantcombo.Text...
3
5000
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 objWord As Word.Application Set objWord = CreateObject("Word.Application") 'Make Application visible With objWord .Visible = True ActiveDocument.MailMerge.MainDocumentType = wdMailingLabels
0
8347
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8792
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8694
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7294
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4280
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
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 we have to send another system
1
1905
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.