To comprehend language, listeners need to encode the relationship between words within sentences. This entails categorizing words into their appropriate word classes. Function words, consistently preceding words from specific categories (e.g., the ballNOUN, I speakVERB), provide invaluable information for this task, and children's sensitivity to such adjacent relationships develops early on in life. However, neighboring words are not the sole source of information regarding an item's word class. Here we examine whether young children also take into account preceding sentence context online during syntactic categorization. To address this question, we use the ambiguous French function word la which, depending on sentence context, can either be used as determiner (the, preceding nouns) or as object clitic (it, preceding verbs). French-learning 18-month-olds' evoked potentials (ERPs) were recorded while they listened to sentences featuring this ambiguous function word followed by either a noun or a verb (thus yielding a locally felicitous co-occurrence of la + noun or la + verb). Crucially, preceding sentence context rendered the sentence either grammatical or ungrammatical. Ungrammatical sentences elicited a late positivity (resembling a P600) that was not observed for grammatical sentences. Toddlers' analysis of the unfolding sentence was thus not limited to local co-occurrences, but rather took into account non-adjacent sentence context. These findings suggest that by 18 months of age, online word categorization is already surprisingly robust. This could be greatly beneficial for the acquisition of novel words.