I am trying to align the element by using my method, however, I get in trouble with getting the current height of the element by using CSS.
This is the code that works, but there will be some extral part.
section{
  margin-top:calc(50vh);
  margin-bottom:calc(50vh);
}<section style="background:red;">q<br><br>q</section>This is what I want to do, but it is not working:
section{
  margin-top:calc(50vh - attr(clientHeight));
  margin-bottom:calc(50vh - attr(clientHeight));
}<section style="background:red;">q<br><br>q</section>I want to know how to get the height of the element, and this question is forcus on this point, but not align an element vertically. Furthermore, I want a CSS-only solution.
 
    