Unicode character for "X" cancel / close?

CssFontsFont Face

Css Problem Overview


I want to create a close button using CSS only.

I'm sure I'm not the first to do this, so does anyone know which font has an 'x' the same width as height, so that it can be used cross-browser to look like a close button?

Css Solutions


Solution 1 - Css

✖ works really well. The HTML code is ✖.

An alternative is &#x2715: ✕

Solution 2 - Css

What about using the ×-mark (the multiplication symbol), × in HTML, for that?

"x" (letter) should not be used to represent anything else other than the letter X.

Solution 3 - Css

× × or × (same thing) U+00D7 multiplication sign

× same character with a strong font weight


⨯ U+2A2F Gibbs product


✖ U+2716 heavy multiplication sign


There's also an emoji ❌ if you support it. If you don't you just saw a square = ❌


I also made this simple code example on Codepen when I was working with a designer who asked me to show her what it would look like when I asked if I could replace your close button with a coded version rather than an image.

<ul>
  <li class="ele">
    <div class="x large"><b></b><b></b><b></b><b></b></div>
    <div class="x spin large"><b></b><b></b><b></b><b></b></div>
    <div class="x spin large slow"><b></b><b></b><b></b><b></b></div>
    <div class="x flop large"><b></b><b></b><b></b><b></b></div>
    <div class="x t large"><b></b><b></b><b></b><b></b></div>
    <div class="x shift large"><b></b><b></b><b></b><b></b></div>
  </li>
  <li class="ele">
    <div class="x medium"><b></b><b></b><b></b><b></b></div>
    <div class="x spin medium"><b></b><b></b><b></b><b></b></div>
    <div class="x spin medium slow"><b></b><b></b><b></b><b></b></div>
    <div class="x flop medium"><b></b><b></b><b></b><b></b></div>
    <div class="x t medium"><b></b><b></b><b></b><b></b></div>
    <div class="x shift medium"><b></b><b></b><b></b><b></b></div>

  </li>
  <li class="ele">
    <div class="x small"><b></b><b></b><b></b><b></b></div>
    <div class="x spin small"><b></b><b></b><b></b><b></b></div>
    <div class="x spin small slow"><b></b><b></b><b></b><b></b></div>
    <div class="x flop small"><b></b><b></b><b></b><b></b></div>
    <div class="x t small"><b></b><b></b><b></b><b></b></div>
    <div class="x shift small"><b></b><b></b><b></b><b></b></div>
    <div class="x small grow"><b></b><b></b><b></b><b></b></div>

  </li>
  <li class="ele">
    <div class="x switch"><b></b><b></b><b></b><b></b></div>
  </li>
</ul>

Solution 4 - Css

HTML

&#x2715;&#x2713;
&#x2716;&#x2714;

&#x2717;
&#x2718;

× &#x00d7; &times;

CSS

If you want to use the above characters from CSS (like i.e: in an :before or :after pseudo) simply use the escaped \ Unicode HEX value, like for example:

[class^="ico-"], [class*=" ico-"]{
  font: normal 1em/1 Arial, sans-serif;
  display: inline-block;
}


.ico-times:before{ content: "\2716"; }
.ico-check:before{ content: "\2714"; }

<i class="ico-times" role="img" aria-label="Cancel"></i>
<i class="ico-check" role="img" aria-label="Accept"></i>

Use examples for different languages:
  • &#x2715; HTML
  • '\2715' CSS like i.e: .clear:before { content: '\2715'; }
  • '\u2715' JavaScript string

https://home.unicode.org/

Solution 5 - Css

✕ is another great one that's not too thick. The HTML code is &#10005;, or 2715 in hex.

Solution 6 - Css

As @Haza pointed out the times symbol can be used. Twitter Bootstrap maps this to a close icon for dismissing content like modals and alerts.

<button class="close">&times;</button>

Solution 7 - Css

 ― 2021 Update

As of Unicode 7.0 (June 2014): U+1F5D9 "Cancellation X"

Solution 8 - Css

I prefer Font Awesome: http://fortawesome.github.io/Font-Awesome/icons/

The icon you would be looking for is fa-times. It's as simple as this to use:

<button><i class="fa fa-times"></i> Close</button>

Fiddle here

Solution 9 - Css

This is probably pedantry, but so far no one has really given a solution "to create a close button using CSS only." only. Here you go:

#close:before {
  content: "✖";
  border: 1px solid gray;
  background-color:#eee;
  padding:0.5em;
  cursor: pointer;
}

http://codepen.io/anon/pen/VaWqYg

Solution 10 - Css

&#x274C;

looks like:

its good for me :)

Solution 11 - Css

there's another one not mentioned here - nice thin - if you need that kind of look for your project: ╳

&#x2573; or decimal: &#9587;

Solution 12 - Css

&times; and font-family: Garamond, "Apple Garamond"; make it good enough. Garamond font is thin and web safe

proper close X

Solution 13 - Css

Forget about a font and use a background image!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" >
	<head>
		<title>Select :after pseudo class/element</title>
		<style type="text/css">
			.close {
				background:url(http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/images/ui-icons_222222_256x240.png) NO-REPEAT -96px -128px;
				text-indent:-10000px;
				width:20px;
				height:20px;
			}
		</style>
	</head>
	<body>
		<input type="button" class="close" value="Close" />
		<button class="close">Close</button>
	</body>
</html>

This will be more accessible for users visiting the page with a screen reader.

Solution 14 - Css

This works nicely for me:

<style>
a.closeX {
    position: absolute;
    right: 0px; top: 0px; width:20px;
    background-color: #FFF; color: black;
    margin-top:-15px; margin-right:-15px; border-radius: 20px;
    padding-left: 3px; padding-top: 1px;
    cursor:pointer; z-index: -1;
    font-size:16px; font-weight:bold;
}
</style>
<div id="content">
    <a class="closeX" id="closeX" onclick='$("#content").hide();'>&#10006;</a>
    Click "X" to close this box
</div>

Solution 15 - Css

This is for people who want to make their X small/big and red!

HTML:

<div class="col-sm-2"> <span><div class="red-x">&#10006;</div></span>
    <p>close</p>
</div>

<div class="red-x big-x">&#10006;</div>

CSS:

.red-x {
color: red;
}

.big-x {
font-size: 70px;
text-align: center;
}

Solution 16 - Css

Using modern browsers you can rotate a + sign:

.popupClose:before {
    content:'+';
}
.popupClose {
    position:relative;
    float:right;
    right:10px;
    top:0px;
    padding:2px;
    cursor:pointer;
    margin:2px;
    color:grey;
    font-size:32pt;
    transform:rotate(45deg);
}

then simply place the following html where you need:

 <span class='popupClose'></span>

Solution 17 - Css

&times; is better than &#10006; as &#10006; behaves strangely in Edge and Internet explorer (tested in IE11). It doesn't get the right color and is replaced by an "emoji"

Solution 18 - Css

You can use text that is only accessible to screen readers by placing it in a span which you hide in an accessible way. Place the x in the CSS which can't be read by screen readers, thus won't confuse, but is visible on the page, and also accessible by keyboard users.

<style>
.hidden {opacity:0; position:absolute; width:0;}
.close {padding:4px 8px; border:1px solid #000; background-color:#fff; cursor:pointer;}
.close:before {content:'\00d7'; color:red; font-size:2em;}
</style>

<button class="close"><span class="hidden">close</span></button>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLeontiView Question on Stackoverflow
Solution 1 - CsseiparkView Answer on Stackoverflow
Solution 2 - CssHazaView Answer on Stackoverflow
Solution 3 - CssdavidcondreyView Answer on Stackoverflow
Solution 4 - CssRoko C. BuljanView Answer on Stackoverflow
Solution 5 - CssemlaiView Answer on Stackoverflow
Solution 6 - CssJohn LehmannView Answer on Stackoverflow
Solution 7 - CssAdámView Answer on Stackoverflow
Solution 8 - CssprograhammerView Answer on Stackoverflow
Solution 9 - CssSteve BennettView Answer on Stackoverflow
Solution 10 - Cssdanday74View Answer on Stackoverflow
Solution 11 - CssPicardView Answer on Stackoverflow
Solution 12 - CssIggyView Answer on Stackoverflow
Solution 13 - CssRichard JP Le GuenView Answer on Stackoverflow
Solution 14 - CsslubarView Answer on Stackoverflow
Solution 15 - CssMaduroView Answer on Stackoverflow
Solution 16 - Cssuser1432181View Answer on Stackoverflow
Solution 17 - CssRaphael PinelView Answer on Stackoverflow
Solution 18 - CssjudyofthewoodsView Answer on Stackoverflow