  Observations of the solar chromosphere in the line-core of the \Halpha\ line
show dark elongated structures called fibrils that show swaying motion. We
performed a 3D radiation-MHD simulation of a network region, and computed
synthetic \Halpha\ images from this simulation to investigate the relation
between fibrils and the magnetic field lines in the chromosphere. The periods,
amplitudes and phase-speeds of the synthetic fibrils are consistent with those
observed. We analyse the relation between the synthetic fibrils and the field
lines threading through them, and find that some fibrils trace out the same
field line along the fibril's length, but there are also fibrils that sample
different field lines at different locations along their length. Fibrils sample
the same field lines on a time scale of $\sim200$~s. This is shorter than their
own lifetime. We analysed the evolution of the atmosphere along a number of
field lines that thread through fibrils and find that they carry slow-mode
waves that load mass into the field line, as well as transverse waves that
propagate with the Alfv\'en speed. Transverse waves propagating in opposite
directions cause an interference pattern with complex apparent phase speeds.
The relationship between fibrils and field lines is complex. It is governed by
constant migration and swaying of the field lines, their mass loading by slow
modes and subsequent draining, and their actual visibility in \Halpha. Field
lines are visible where they lie close to the optical depth unity surface. The
location of the latter is governed by the height at which the column mass in
the chromosphere reaches a certain value. We conclude that using the swaying
motion of fibrils as a tracer of chromospheric transverse oscillations must be
done with caution.
