I want to set the height of a div based on CSS expression.
Basically it should be set as some % (say 90%) of the viewport width I tried the follow
You're combining CSS and javascript, which will not work.
You either want to just set height:90%; (which will do 90% of the width of the parent element, not the page - unless the div is at the root of the page).
Otherwise you should create a javascript block (preferably as part of an onload script), e.g... (not tested)
Edit - Thanks @Chris for pointing out that the questioner was asking for the height to be set, not the width.
I think javascript is your only way of doing this...