Reorder html tags and variables so tags get precedence