How do I convert longhand hex to RGB(A)? For example, I have the following code to convert all formats of hex, colorname, etc.. to RGBA for background opacity, but for some reason longhand hex does not work, but instead takes the shorthand from the longhand (eg. background-color: #0000ff; becomes background-color: #000;). Alot of the code below is based off of