Dinosaurs ruled Earth for approximately 165 million years — longer than mammals have existed. This is a mind-bending timescale that puts human history (recorded history is ~5,000 years) into perspective.
Dinosaurs did not all vanish instantly. The extinction was triggered by a massive asteroid impact in what is now Mexico (the Chicxulub crater), combined with massive volcanic eruptions in India. The impact created a global dust cloud that blocked sunlight for months, collapsing ecosystems. Large dinosaurs could not survive the sudden climate shift and food chain collapse.
Smaller dinosaurs — specifically theropods — did survive and evolved into modern birds. So technically, dinosaurs never fully went extinct; they are still here, just feathered and much smaller.
Pro tip: The reign of dinosaurs was so long that Triceratops and T-Rex were closer in time to humans today than to the earliest dinosaurs. If dinosaurs ruled for 165 million years, T-Rex and Triceratops lived only in the last 3-4 million years of that span. Time scales this vast are genuinely difficult for human brains to grasp — it helps to compare: we have had cities for ~10,000 years, farming for ~12,000 years, and civilization as we know it for only ~2,000 years.