-->

Where can I find a list of all special HTML charac

2019-01-20 04:28发布

问题:

I'm in the process of adding various physics equations to a website. There are several special characters I've needed to add, and I haven't been able to find some of them (for instance, I need to add a curled "E" to denote energy density, and I need to add an H with the '^' symbol on top to denote the Hamiltonian operator).

Thus, I was wondering if anyone has compiled a table of all the various HTML special characters (such as ħ for h-bar, which equals h/2PI). If so, a link would be much appreciated! Thanks!

回答1:

How about this, from the w3 org:

http://dev.w3.org/html5/html-author/charref



回答2:

With just a bit of Javascript you can build your own:

Unicode UTF-8 characters generator

function el(id) {return document.getElementById(id); }

var from = 8000; // Start from 
var show = 1000; // How many to show
var cont = el("container");
var prev = el("prev");
var next = el("next");
var curr = el("curr"); 


function prevNext(){
  from = this.id === "next" ? from+=show : from-=show;
  if(from>=0)createUnicodeChars();
  else from=0;
}

function createUnicodeChars() {
  var spans = "";
  for(var i=from; i<from+show; i++){
    var uc = i.toString(16);
    spans += "<span>&#"+i+";<br><small>&amp;#"+i+";<br>\\"+uc+"</small></span>";
  }

  curr.innerHTML = from +' - '+ (from+show);
  cont.innerHTML = spans;
}

prev.onclick = prevNext;
next.onclick = prevNext;

createUnicodeChars(); // First run!
body{background:#eee;}
span{
  position:relative;
  display:inline-block;
  width: 80px;
  padding:10px;
  height:80px;
  margin:3px;
  font-size:2em;
  text-align:center;
  vertical-align:top;
  background:#fff;
  border:1px solid #aaa;
  border-radius:5px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.1);
}
span small{
  position:absolute;
  width:80%;
  bottom:5px;
  text-align:ccenter;
  display:block;
  font-size:12px;
  line-height:14px;
}
#container{
  margin-top:50px;
  text-align:center;
}
#controls{
  background:#fff;
  box-shadow: 0 0 20px #000;
  position:fixed;
  z-index:1;
  top:0;
  left:0;
  padding:10px;
  width:100%;
  text-align:center;
}
<div id="controls">
      <button id="prev">PREV</button>
      <b id="curr"></b>
      <button id="next">NEXT</button>
</div>
<div id="container"></div>

Will give you the Character representation,
the numerical HTML encoding &#num; of the Unicode character,
the UTF-8 Hex. code \hex (you can use in CSS :after or :before content: jsBin)