This is a situation I recently faced. I will share with you the why and what of my actions.
I was trying to load the car with the diaper bag, a large stack of boxes for the mailbox, and my children. Just as I got the last box in, out of the corner of my eye I saw that my little one put his foot in the street.
I turned and yelled, "STOP!" I didn't use a you-are-in-so-much-trouble voice, but more of a panicked-what-if-there-were-a-car voice. I ran over to him, as if though he had been hurt by a car. And scooped him up and said, "Are you alright?" over and over. I started kissing his arms and legs, "telling him that I was so happy his arms were safe and his legs didn't get hurt."
I think that my mind's eye had taken me to the moment of a car crash and I wanted him to feel my fear that something really bad could happen (more than anger or a casual response). I wanted him to feel the gravity. And when I started crying (yes, I am pretty sure the tears were more real than forced), I then told him that it isn't safe...something very bad could happen (I think I used the words tire and squish - but I can't remember) and that he always has to hold my hand in the street. He started crying a little bit, realizing how serious, not because I was angry, but because he had done something that made me scared and very sad.
We haven't had another problem. He is very careful, and I have now empowered him to help me check both ways and tell me when it is safe. But, he always has a hand.
So, that is the what. The why is that sometimes I think helping a child understand the emotion behind a serious situation helps them learn. Sure, some kids can be told not to go near the street, and just won't. But, I think it is important to help teach them, that it isn't just a rule - don't eat on the couch - or something. That it is about safety, and the consequence could be really big.
I am sure there are other ways, so please share what has worked for you...
Painting: Paris Street, Rainy Day, 1877/Gustave Caillebotte — The Art Institute of Chicago