The first time I was given this advice was in primary school. I think I was about ten years old–already in love with writing stories, so much so that I did it in my spare time. I imagine it was well-meaning adults who told me this, because no child would ever have thought to limit themselves to writing what they knew. Children write about fantastic creatures and foreign countries and space travel, none of which they have experienced. Children know that all they need is their imagination to create a story. The details are, well, details.
When you get older, then details become more important. So ‘write what you know’ sounds like good advice, for an aspiring adult writer. People are a lot less forgiving of major plot flaws or unrealistic characters when you’re writing a story as an adult, than they are when you’re ten. It’s best, then, to make sure you do know what you’re writing about.
But this shouldn’t mean you should only write about your own experiences–far from it. Take the academic work that I edit. Some of these dissertations are tens of thousands of words on a specific subject. The student obviously knows a lot about their topic, but that’s the result of years of research and study. They’re writing what they know–because they just spent an enormous amount of effort learning it. I’m always in awe of how much work goes into these theses, and I love how much I also learn from reading them.
So yes, write what you know. But if you don’t know about it, then that’s not a reason to give up. You just need to learn. Read. Research. Ask questions. Find out.
And then you’ll know.