The grainline is a line that (in most cases) runs vertically down the length of a pattern. In some cases it will run horizontally or on the bias (when a piece is cut on the diagonal grain to increase the drape and fluidity of the piece), depending on the pattern piece.
The grainline is there to ensure that the pattern piece is placed on the fabric correctly, and therefore cut the way it was intended to be by the pattern maker. You do this by lining up the grainline with the selvedge (the uncut edge of the fabric that has been woven to prevent the fabric unravelling) of the fabric, checking that the grainline is equidistant from the grainline at regular intervals.
On many commercial patterns the grainline will not run from one end of the pattern to the other (as in my example) and will be somewhat shorter. I prefer to mark my grianline from one end to the other, as it can be helpful when working with prints, especially vertical stripes! I also find that it helps with accuracy.
When marking the grainline on the front or back pattern pieces, I find it handy to mark the grainline on the centre front or centre back (where possible), so that you never lose sight of these points. On other pattern pieces, it is best to place the grainline towards the centre of the piece, as this will help get the piece balanced, when checking that it is lined up with the selvedge.
As well as this, I like to add arrows at each end of my grainline to show the direction the pattern should be placed on the fabric (double arrow towards the top and single arrow towards the bottom). This may not seem necessary, but can be very handy when cutting irregular shaped pattern pieces or directional prints.
Whoa. I didn't know I had so much to say about grainlines!