JSFiddle - React, Tailwind, and code Playground
HTML
<div id="health" style="background-color:green;min-height:5px;"></div>
JavaScript
var hp = 500;
var max = 2500;
var perc = Math.round(hp/max * 100);
if(perc > 100) perc = 100;
else if(perc < 0 ) perc = 0;
d = document.getElementById('health');
d.style.width= perc+"%";
alert(perc);