Overview
Appropriate music symbols, depending upon the intended effect, are placed on the staff according to their corresponding pitch or function. Musical notes are placed by pitch, percussion notes are placed by instrument, and rests and other symbols are placed by convention.
The absolute pitch of each line of a non-percussive staff is indicated by the placement of a clef symbol at the appropriate vertical position on the left-hand side of the staff (possibly modified by conventions for specific instruments). For example, the treble clef, also known as the G clef, is placed upon the second line (counting upwards), fixing that line as the pitch first G above 'middle C'.
The lines and spaces are numbered from bottom to top; the bottom line is the first line and the top line is the fifth line.
The musical staff is analogous to a mathematical graph of pitch with respect to time. Pitches of notes are given by their vertical position on the staff and notes to the left are played before notes to the right. Unlike a graph, however, the number of semitones represented by a vertical step from a line to an adjacent space depends on the key, and the exact timing of the beginning of each note is not directly proportional to its horizontal position; rather, exact timing is encoded by the musical symbol chosen for each note in addition to the tempo.
A time signature to the right of the clef indicates the relationship between timing counts and note symbols, while bar lines group notes on the staff into measures.
Staff positions
The vertical position of the notehead on the staff indicates which note to play: higher-pitched notes are marked higher on the staff. The notehead can be placed with the center of its notehead intersecting a line (on a line), or in between the lines touching the lines above and below (in a space). Notes outside the range of the staff are placed on or between ledger lines—lines the width of the note they need to hold—added above or below the staff.
Exactly which staff positions represent which notes is determined by a clef placed at the beginning of the staff. The clef identifies a particular line as a specific note, and all other notes are determined relative to that line. For example, the treble clef puts the G above middle C on the second line. The interval between adjacent staff positions is one step in the diatonic scale. Once fixed by a clef, the notes represented by the positions on the staff can be modified by the key signature, or by accidentals on individual notes. A clefless staff may be used to represent a set of percussion sounds; each line typically represents a different instrument.
History
Early Western medieval notation was written with neumes, which didn't specify exact pitches but only the shape of the melodies, i.e. indicating when the musical line went up or down; presumably these were intended as mnemonics for melodies which had been taught by rote.
During the 9th through 11th centuries a number of systems were developed to specify pitch more precisely, including diastematic neumes whose height on the page corresponded with their absolute pitch level (Longobardian and Beneventan manuscripts from Italy show this technique around AD 1000). Digraphic notation, using letter names similar to modern note names in conjunction with the neumes, made a brief appearance in a few manuscripts, but a number of manuscripts used one or more horizontal lines to indicate particular pitches.
The treatise Musica enchiriadis (AD 900) uses Daseian notation for indicating specific pitches, but the modern use of staff lines is attributed to Guido d'Arezzo (AD 990-1050), whose four-line staff is still used (though without the red and yellow coloring he recommended) in Gregorian chant publications today. Five-line staves appeared in Italy in the 13th century, and staves with four, five, and six lines were used as late as 1600.