Class 8A: the ratio of girls to boys is 18:24. The HCF of 18 and 24 is 6.
18:24=(18÷6):(24÷6)=3:4
Class 8B: the ratio of girls to boys is 21:28. The HCF of 21 and 28 is 7.
21:28=(21÷7):(28÷7)=3:4
Both ratios have the same simplest form, 3:4. So yes, the ratios are proportional: 18:24::21:28.
Check by cross multiplication: 18×28=504 and 24×21=504.