It depends on the share. First of all, the two mostly commonly kind of shares are the preference and the ordinary shares.
Preference shares usually have dividend that is accumulated every year if when not paid. So for example, these shares will you a certain amount of dividend per year and if not paid in a year, it is a liability for the company and it will be paid at some point in the future.
Another difference is between redeemable and irredeemable preference shares. Redeemable preference shares are considered as debt and not as equity. So dividends for these shares are indeed an expense. For irredeemable preference shares, the credit goes to the reserves (profit and loss account) and it does not appear in the income statement.
The most common share class is the ordinary shares. The ordinary shares (the most common case) do not have accumulation of dividends so only when a dividend is declared by the board, it can be posted. If it is not declared, it will not be recognized.