I would like to draw something simple like this using HTML and CSS:
|_____|_____|_____|_____|
with aligned numbers underneath each vertical bar, e.g. 0, 1, 2, 3, 4
etc.
I would also like to adjust the space between bars programmatically. Is there any example I can follow?
Here is a good example:
https://codepen.io/cfenzo/pen/jEGQGm
or another example
https://codepen.io/pbweb/pen/grQKEK
I try never to preach using tables for non-tabular data, but you could just do it using a table:
A fiddle: http://jsfiddle.net/ZH7Lx/
Here are some CSS on-screen rulers in a fiddle :-p There are probably better/fancier ways to set the spacing, but I included a simple example that loops through and adjusts the salient values.
Check this out: http://jsfiddle.net/thirdender/kwcug/
Looks more fancy and can be easily customized.
A static answer:
To be able to change it, use JavaScript.