CSS Disable Cursor

CSS Disable Cursor

CSS Disable Cursor

In web design, we often use CSS to beautify page elements. One common requirement is to control the cursor style. Sometimes we want to prevent users from using the mouse on certain elements. This requires disabling the cursor. This article will detail how to achieve this using CSS.

1. Using the cursor Property

In CSS, we can use the cursor property to control the cursor’s style. To disable the cursor, set the cursor property to none. Here is a simple sample code:


<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, Initial scale = 1.0">
<title>Disable Cursor Example</title>
<style>
.no-cursor {
cursor: none;
}
</style>

</head>
<body>
<div class="no-cursor">Disable Cursor Example</div>

</body>

</html>

Code Running Result:

CSS Disable Cursor

In the example above, we added a class named no-cursor to a div element and set the cursor in CSS: none;, which will disable the cursor from displaying on this div element.

2. Disable cursor on links

Sometimes we want to disable the cursor on links. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable cursor on links example</title> 
<style> 
.no-link { 
cursor: default; 
} 
</style> 
</head> 
<body> 
Disable cursor on links example 
</body> 
</html> 

Code running results:

CSS Disable cursor

In the example above, we added a class called no-link to a link element a and set cursor: default; in CSS to disable the cursor from displaying on the link.

3. Disable the cursor on the input box

Sometimes we want to disable the cursor on the input box. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the input box example</title> 
<style> 
.no-input { 
cursor: not-allowed; 
} 
</style> 
</head> 
<body> 
<input type="text" class="no-input" placeholder="Disable cursor over input box example">

</body>

</html>

Code running results:

CSS Disallow Cursor

In the above example, we add a class named no-input to an input box input element and set cursor: not-allowed; in CSS to prevent the cursor from being displayed over the input box.

4. Disable the cursor on the button

Sometimes we want to disable the cursor on the button. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable cursor on button example</title> 
<style> 
.no-button { 
cursor: pointer; 
} 
</style> 
</head> 
<body> 
<button class="no-button">Disable cursor on button example</button> 
</body> 
</html> 

Code running results:

CSS Disable cursor

In the example above, we added a class named no-button to a button element and set cursor: pointer; in CSS to disable the cursor from displaying on the button.

5. Disable the cursor on https://coder-cafe.com/wp-content/uploads/2025/09/images

Sometimes we want to disable the cursor on https://coder-cafe.com/wp-content/uploads/2025/09/images. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on https://coder-cafe.com/wp-content/uploads/2025/09/images</title> 
<style> 
.no-image { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<img src="https://www.geek-docs.com/https://coder-cafe.com/wp-content/uploads/2025/09/image.jpg" class="no-image" alt="Disable cursor on image" example">

</body>

</html>

Code execution result:

CSS Disable Cursor

In the example above, we add a class named no-image to an image img element and set cursor: default; in CSS to disable the cursor from displaying on the image.

6. Disable the cursor on the table

Sometimes we want to disable the cursor on the table. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the table</title> 
<style> 
.no-table { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<table class="no-table"> 
<tr> 
<td>Disable the cursor on the table</td> 
</tr> 
</table> 
</body> 
</html> 

Result of running the code:

CSS Disable Cursor

In the example above, we added a class named no-table to a table element and set cursor: default; in CSS to disable the cursor from displaying on the table.

7. Disabling the cursor on a list

Sometimes we want to disable the cursor on a list. You can use the following example code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disabling the cursor on a list</title> 
<style> 
.no-list { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<ul class="no-list"> 
<li>Disabling the cursor on a list</li> 
</ul> 
</body> 
</html> 

Result of running the code:

CSS Disable Cursor

In the example above, we added a class named no-list to the list element ul and set cursor: default; in CSS to disable the cursor from displaying on the list.

8. Disable cursor on DIV

Sometimes we want to disable the cursor on DIV. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable cursor on DIV example</title> 
<style> 
.no-div { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<div class="no-div">Disable cursor on DIV example</div> 
</body> 
</html> 

Code running result:

CSS Disabling the cursor

In the example above, we added a class named no-div to a div element and set cursor: default; in CSS to disable the cursor from displaying on this div element.

9. Disable the cursor on the paragraph

Sometimes we want to disable the cursor on the paragraph. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the paragraph example</title> 
<style> 
.no-paragraph { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<p class="no-paragraph">Disable the cursor on the paragraph example</p> 
</body> 
</html> 

Code running result:

CSS Disabling the cursor

In the example above, we added a class named no-paragraph to a paragraph p element and set cursor: default; in CSS to disable the cursor from displaying on this paragraph.

10. Disable the cursor on the title

Sometimes we want to disable the cursor on the title. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the title example</title> 
<style> 
.no-heading { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<h1 class="no-heading">Disable the cursor on the title example</h1> 
</body> 
</html> 

Code running result:

CSS Disabling the cursor

In the example above, we added a class named no-heading to a heading h1 element and set cursor: default; in CSS to disable the cursor from displaying on this heading.

11. Disable the cursor on the text box

Sometimes we want to disable the cursor on the text box. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the text box example</title> 
<style> 
.no-textarea { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<textarea class="no-textarea" placeholder="Example of disabling the cursor on a text box"></textarea>

</body>

</html>

Code Running Result:

CSS Disabling Cursor

In the example above, we add a class named no-textarea to a text box textarea element and set cursor: default; in CSS to disable the cursor from displaying on the text box.

12. Disable the cursor on the drop-down box

Sometimes we want to disable the cursor on the drop-down box. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the drop-down box example</title> 
<style> 
.no-select { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<select class="no-select"> 
<option value="1">Disable the cursor on the drop-down box example</option> 
</select> 
</body> 
</html> 

Code Running Results:

CSS Disable Cursor

In the above example, we added a class named no-select to a drop-down box select element and set cursor: default; in CSS to disable the cursor from displaying on the drop-down box.

13. Disable the cursor on the radio button

Sometimes we want to disable the cursor on the radio button. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the radio button example</title> 
<style> 
.no-radio { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<input type="radio" class="no-radio" name="radio" Example of disabling the cursor over a radio button

</body>

</html>

Result of running the code:

CSS Disabling Cursor

In the example above, we add a class named no-radio to a radio button input element and set cursor: default; in CSS to disable the cursor from displaying over the radio button.

14. Disable the cursor on the checkbox

Sometimes we want to disable the cursor on the checkbox. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the cursor on the checkbox example</title> 
<style> 
.no-checkbox { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<input type="checkbox" class="no-checkbox" name="checkbox" Example of disabling the cursor on a checkbox

</body>

</html>

Result of running the code:

CSS Disabling Cursor

In the example above, we add a class named no-checkbox to a checkbox input element and set cursor: default; in CSS to disable the cursor from appearing on the checkbox.

15. Disable the Scrollbar Cursor

Sometimes we want to disable the scrollbar cursor. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable the Scrollbar Cursor Example</title> 
<style> 
::-webkit-scrollbar { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<div style="height: 200px; overflow: Example of disabling the cursor on the scrollbar.</div>

</body>

</html>

Code Running Results:

CSS Disabling Cursor

In the above example, we use the CSS pseudo-element ::-webkit-scrollbar to control the scrollbar style and set cursor: default; to disable the cursor from displaying on the scrollbar.

16. Disable Cursor Dragging on Elements

Sometimes we want to disable cursor dragging on an element. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable Cursor Dragging on Elements Example</title> 
<style> 
.no-drag { 
cursor: default; 
} 
</style> 
</head> 
<body> 
<div class="no-drag" Example of disabling the cursor on an element with draggable="true"></div>

</body>

</html>

Result of running the code:

CSS Disabling Cursor

In the example above, we add a class named no-drag to a div element, set cursor: default; in CSS, and set the draggable="true" attribute to prevent the cursor from appearing when dragging on this element.

17. Disable Cursor on Links

Sometimes we want to disable the cursor on links. You can use the following sample code:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Disable Cursor on Link Example</title> 
<style> 
.no-link { 
cursor: default; 
} 
</style> 
</head> 
<body> 
Disable Cursor on Link Example 
</body> 
</html> 

Code Running Result:

CSS Disable Cursor

In the above example, we added a class named no-link to a link element a and set cursor: default; in CSS to disable the cursor on this link.

These examples show how to disable the cursor on different elements using CSS. You can choose the method that suits your needs.

Leave a Reply

Your email address will not be published. Required fields are marked *