-5

I have following html code:

<div style="column-count: 3;">
    <ul>
        <li><h3>Education<h3></li>
        <li><a>Education 1</a></li>
        <li><a>Education 2</a></li>
        <li><a>Education 3</a></li>
    </ul>
    <ul>
        <li><h3>Careers<h3></li>
        <li><a>Careers1</a></li>
        <li><a>Careers2</a></li>
        <li><a>Careers3</a></li>
    </ul>
    <ul>
        <li><h3>Legal<h3></li>
        <li><a>Legal</a></li>
        <li><a>Legal</a></li>
        <li><a>Legal</a></li>
    </ul>
</div>

It divides the ul's into 3 columns. The following picture explains above code:

enter image description here

As you can see, Education is at the bottom of the first column, it looks weird because it's subsequent anchor tags are moved to the next column. I want to move Education to the next column as well in such case. Any CSS or JS solution?

Koby Douek
  • 16,156
  • 19
  • 74
  • 103
Saad Zulfiqar
  • 410
  • 5
  • 16
  • why don't you use blank ```li``` there? ```
  • ``` this can also work try it – Ashish sah Aug 28 '17 at 13:14
  • 1
    Don't paste code to the comment section, edit your question, and add you code there. – Koby Douek Aug 28 '17 at 13:14
  • @AlivetoDie The actual problem is that he asks for a CSS or JS solution of moving a html element. I would really love to see a CSS that can do that. – user5014677 Aug 28 '17 at 13:18
  • This is an incorrect usage of a list item and that is the cause of this issue. Your heading element will be treated the same as the other list items. You need to rethink your layout and put them all in a sectioning element instead. – Rob Aug 28 '17 at 13:23
  • Actually this is the dynamic code i am getting via service. Can't do anything @Rob. – Saad Zulfiqar Aug 28 '17 at 13:27
  • With CSS you can do this https://jsfiddle.net/ppcfL7sg/ ... but you can't explicit only target _if_ the header is the last, as there is no _last-child-in-column_ property. For that it takes a script. – Asons Aug 28 '17 at 14:13