Single T4-DNA molecules were confined in rectangular-shaped channels with a depth of 300 nm and a width in the range 150-300 nm casted in a poly(dimethylsiloxane) nanofluidic chip. The extensions of the DNA molecules were measured with fluorescence microscopy as a function of the ionic strength and composition of the buffer as well as the DNA intercalation level by the YOYO-1 dye. The data were interpreted with scaling theory for a wormlike polymer in good solvent, including the effects of confinement, charge, and self-avoidance. It was found that the elongation of the DNA molecules with decreasing ionic strength can be interpreted in terms of an increase of the persistence length. Self-avoidance effects on the extension are moderate, due to the small correlation length imposed by the channel cross-sectional diameter.Intercalation of the dye results in an increase of the DNA contour length and a partial neutralization of the DNA charge, but besides effects of electrostatic origin it has no significant effect on the bare bending rigidity. In the presence of divalent cations, the DNA molecules were observed to contract, but they do not collapse into a condensed structure. It is proposed that this contraction results from a divalent counterion mediated attractive force between the segments of the DNA molecule.