HTML opacity attribute vs CSS opacity
问题 I know of two different ways of setting opacity in HTML: <div opacity="0.5"></div> and <div style="opacity: 0.5;"></div> I also know how to set both of those in JavaScript: div.setAttribute("opacity", 0.5); and div.style.opacity = 0.5 Are there any major differences between those two methods? Should I prefer one over the other? (I guess I should at least be consistent) 回答1: The only opacity attribute I am aware of is for use with SVGs: Example Elements The following elements can use the