Math operations within HTML -


is possible perform math operations within html, <div width="50/2">? or can done using javascript or css?

no, html , css can not perform math operations. can in javascript. if have choice should not perform complex math operations javascript unless know javascript well. because javascript has weird behaviour example:

document.write(.1 + .2)  // 0.3000000000000004  (instead of 0.3) document.write(.3 + .6)  // 0.8999999999999999  (instead of 0.9) 

but long dealing integer values should fine. or if want deal decimals in javascript convert them integer (by multiplying 100 , convert result decimal divinding 100.)

you can use other languages along html , css on server side:

  • php
  • python
  • java
  • ruby
  • javascrript (both server , client side)

which can math , more.

but if computing layout features example making calculation width , height add in css guess should use javascript. read little unexpected behavior decimals. don't wrong result.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -