used dir attribute instead of css rule direction for switching writing direction based on the suggestion about dir on mdn