We present near-simultaneous X-ray and optical polarization measurements in the high synchrotron peaked (HSP) blazar Mrk 421. The X-ray polarimetric observations were carried out using Imaging X-ray Polarimetry Explorer (IXPE) on 2023 December 6. During IXPE observations, we also carried out optical polarimetric observations using 104 cm Sampurnanand telescope at Nainital and multiband optical imaging observations using 2 m Himalayan Chandra Telescope at Hanle. From model-independent analysis of IXPE data, we detected X-ray polarization with degree of polarization (ΠX) of 8.5% ± 0.5% and an electric vector position angle (ΨX) of 10.°6 ± 1.°7 in the 2−8 keV band. From optical polarimetry on 2023 December 6, in B, V, and R bands, we found values of Π B = 4.27% ± 0.32%, Π V = 3.57% ± 0.31%, and Π R = 3.13% ± 0.25%. The value of Π B is greater than that observed at longer optical wavelengths, with the degree of polarization suggesting an energy-dependent trend, gradually decreasing from higher to lower energies. This is consistent with that seen in other HSP blazars and favors a stratified emission region encompassing a shock front. The emission happening in the vicinity of the shock front will be more polarized due to the ordered magnetic field resulting from shock compression. The X-ray emission, involving high-energy electrons, originates closer to the shock front than the optical emission. The difference in the spatial extension could plausibly account for the observed variation in polarization between X-ray and optical wavelengths. This hypothesis is further supported by the broadband spectral energy distribution modeling of the X-ray and optical data.