How to make an area unclickable with CSS? (2024)

How to make an area unclickable with CSS? (1)

  • Data Structure
  • Networking
  • RDBMS
  • Operating System
  • Java
  • MS Excel
  • iOS
  • HTML
  • CSS
  • Android
  • Python
  • C Programming
  • C++
  • C#
  • MongoDB
  • MySQL
  • Javascript
  • PHP
  • Physics
  • Chemistry
  • Biology
  • Mathematics
  • English
  • Economics
  • Psychology
  • Social Studies
  • Fashion Studies
  • Legal Studies
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary
  • Who is Who

CSSWeb DevelopmentFront End Technology

'; var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd(ad_id); });

In this article, to make a given area unclickable we will use the CSS property pointer-events by assigning it to none value to get the required area unclickable.

Pointer events is a contemporary way to handle input from a spread of inform devices, like a mouse, a pen/stylus, a touchscreen, and so on.

The pointer-events CSS property sets beneath what circ*mstances (if any) a specific graphic component will become the target of pointer events. This property is employed to specify whether or not component shows pointer events and whether or not shows on the pointer.

Syntax

In CSS, we use the following syntax of the pointer-event used a CSS property −

pointer-events: auto;pointer-events: none;

Parameters

  • Auto − The element behaves as it would if the pointer-events property were not specified. In SVG content, this value and the value visiblePainted have the same effect.

  • None − The element is never the target of pointer events; however, pointer events may target its descendant elements if those descendants have pointer-events set to some other value. In these circ*mstances, pointer events will trigger event listeners on this parent element as appropriate on their way to/from the descendant during the event capture/bubble phases.

Note − By default, the set value of pointer-event is ‘auto’.

We have provided the solution in the following approach −

  • By Using pointer-events property.

Let’s see the program along with its output one by one.

Approach: By Using pointer-events property Of CSS

In this approach, we will be making a given image unclickable, the whole area covered by the given image will be unclickable using the CSS property pointer-event with the href attribute along with it we are using the pointer-events CSS property which sets whether the element in the page has to respond or not while clicking on elements along with the href within a class to maker the image unclickable within the <a> tag. For the image, we use the <img> tag as well as the <a> tag with the href attribute. The <img> tag is for using an image in a web page and the <a> tag is for adding a link. Add the image's URL to the src attribute of the image tag. Add the height and width in addition to that.

A specific visual element's ability to become the target of pointer events is controlled by the pointer-events CSS property, which specifies whether or not they can.

The inline CSS method has been used under this approach since the pointer event is a genetic CSS property that can be applied equally well to any CSS method since it is a genetic CSS property.

Note − The use of pointer-events in CSS for non-SVG elements is experimental. The feature used to be part of the CSS 3 UI draft specification but, due to many open issues, has been postponed to CSS 4.

Syntax

The following is the generic syntax to pointer-events CSS property where in parameter it takes property accordingly.

Pointer-events: none;

Example-1

In the following program, we have used the internal CSS by adding the style tag inside it we have created a class that has pointer-event to none with the properties of a simple circle to make the area covered by the circle unclickable along with the <a> tag and added a link to its href attribute in HTML programming language.

<!DOCTYPE html><html <head> <meta charset="utf-8"> <title>Disable a href Link using CSS</title> </head> <style> .unclickable{ pointer-events: none; height: 250px; width: 250px; background-color: blue; border-radius: 50%; display: inline-block; } </style> <body> <h3>The below area covered by the circle is unclickable:-</h3> <a class="unclickable" href="tutorialspoint.html"></a> </body></html>

Example-2

In the following program, we have used the inline CSS by adding the style attribute with the <a> tag followed by adding the pointer-event to none into it which will make the used image unclickable to any user in HTML programming language.

<!DOCTYPE html><html> <head> <title>HTML Image as link</title> </head> <body> The following image is unclickable as a link:<br> <a style=" pointer-events: none; "href="https://www.tutorialspoint.com/"> <img alt="Qries" src="https://www.tutorialspoint.com/cg/images/logo.png" width=300" height="100"> </a> </body></html>

Supported Browsers − The browsers supported by pointer-events Property are listed below −

  • Google Chrome 1.0
  • Edge 12.0
  • Internet Explorer 11.0
  • Firefox 1.5
  • Opera 9.0
  • Safari 4.0

This article was focused on how to make an area that is unclickable with CSS by using the pointer-events property of the CSS specification.

Geetansh Sahni

Updated on: 12-Dec-2022

13K+ Views

Related Articles

  • How to scale down an image with CSS to make it responsive
  • How to make a histogram with bins of equal area in Matplotlib?
  • How to declare the painting area of the background with CSS
  • How to delay an animation with CSS
  • How to center an image with CSS?
  • Make a font italic with CSS
  • How to make horizontal line with words in the middle using CSS?
  • How to create an image gallery with CSS
  • How to create an email newsletter with CSS?
  • How to create an avatar image with CSS?
  • How to create an overlay effect with CSS?
  • How to style an hr element with CSS?
  • How to create Area Chart using CSS
  • How to make an android spinner with initial default text?
  • How to make an svg scale with its parent container
Kickstart Your Career

Get certified by completing the course

Get Started

How to make an area unclickable with CSS? (31)

Advertisem*nts

';adpushup.triggerAd(ad_id); });

How to make an area unclickable with CSS? (2024)

FAQs

How to make an area unclickable with CSS? ›

To make an image not clickable using CSS, you can use the "pointer-events" property and set it to "none". This will disable any click or hover events on the image, making it unclickable. Additionally, you can also use the "cursor" property and set it to "default" to visually indicate that the image is not clickable.

How do you make everything Unclickable in CSS? ›

Use the pointer-events CSS property: You can use the pointer-events property to specify whether or not an element is clickable. To make an element unclickable, you can set the pointer-events property to none .

How do you make something not selectable in CSS? ›

To do this you must use the user-select: none; CSS rule. The browser support for this declaration is good with browser prefixing still needed. Latest versions of Firefox, Edge and Chrome no longer need the prefix, whilst Safari and Internet Explorer need the prefix.

How do you make an input Unclickable in CSS? ›

In this article, to make a given area unclickable we will use the CSS property pointer-events by assigning it to none value to get the required area unclickable. Pointer events is a contemporary way to handle input from a spread of inform devices, like a mouse, a pen/stylus, a touchscreen, and so on.

How do I make text Unclickable in CSS? ›

All you need to do is add this line of CSS: user-select: none; And you're done :) And that's all there is to making text unselectable in CSS.

How to make unclickable in HTML? ›

To make a link unclickable, you can simply display the URL or text without hyperlinking it. In HTML, this can be achieved by wrapping the link text or URL in a <span> or <div> tag without specifying an href attribute.

How to make an input field not clickable? ›

The disabled attribute is a boolean attribute. When present, it specifies that the <input> element should be disabled. A disabled input element is unusable and un-clickable.

How do I make an area not clickable in CSS? ›

To make an image not clickable using CSS, you can use the CSS pointer-events property. This property allows you to control whether an element can be the target of pointer events, such as clicks or hover effects. By setting pointer-events: none; , you can disable the Click ability of an image.

How do you disable selectable in HTML? ›

The disabled attribute can be set to keep a user from selecting the option until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the disabled value, and make the option selectable.

How do you make an option not selectable in HTML? ›

Adding the disabled attribute to the first option makes the option unselectable. You can add form validation to require the user to select an option.

Is it unclickable or non clickable? ›

Adjective. unclickable (not comparable) (computing) Not clickable.

How to make a button not clickable in HTML? ›

How do I make a button not clickable? Simply add the disabled attribute in HTML or set the disabled property to true in JavaScript. How to disable input button in HTML? Add disabled directly in the button element: <input type="button" disabled> .

How do I ignore right click in CSS? ›

Using CSS. You can also use CSS to disable right-click functionality on a web page by using its pointer-events. What you can do is set the 'pointer-events' property to 'none' for all those elements that you want to specifically disable the right click on.

How to make checkbox unclickable CSS? ›

Using the pointer-events property

This approach is using the pointer-events CSS property to the input tag which is representing the checkboxes. When this CSS property is given as design to the input tag, the checkbox is essentially read-only so you can view the checkbox but cannot interact with it.

How do I make text not responsive in CSS? ›

Just add white-space: nowrap; to the container. You could try giving them a minimum width and height by using min-width and min-height properties in your style tags. Make sure not to use relative units of measure such as vh, em, or rems use pixels instead to ignore screen size completely.

How do I disable click in CSS class? ›

The `:disabled` pseudo-class selector targets the disabled state of an element, allowing you to modify its appearance and behavior. This CSS code applies the specified styles to all disabled buttons, making them appear grayed out and unclickable.

How do I force text to not break in CSS? ›

The white-space property has numerous options, all of which define how to treat white space inside a given element. Here, you have set white-space to nowrap , which will prevent all line breaks.

How do you force no break in CSS? ›

The simplest way to solve this problem is to use the white-space CSS property and set it to "nowrap" for the specific . cell containing "total steps." It will prevent line breaks within the “total steps” cell, and the text will remain on a single line even if the container's width is limited.

How to disable right click CSS? ›

Using CSS. You can also use CSS to disable right-click functionality on a web page by using its pointer-events. What you can do is set the 'pointer-events' property to 'none' for all those elements that you want to specifically disable the right click on.

Top Articles
Latest Posts
Article information

Author: Barbera Armstrong

Last Updated:

Views: 6061

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Barbera Armstrong

Birthday: 1992-09-12

Address: Suite 993 99852 Daugherty Causeway, Ritchiehaven, VT 49630

Phone: +5026838435397

Job: National Engineer

Hobby: Listening to music, Board games, Photography, Ice skating, LARPing, Kite flying, Rugby

Introduction: My name is Barbera Armstrong, I am a lovely, delightful, cooperative, funny, enchanting, vivacious, tender person who loves writing and wants to share my knowledge and understanding with you.