Jennifer Lopez
Singer Jennifer Lopez arrives at the BAFTA Brits to Watch event in Los Angeles, California July 9, 2011. Britain's Prince William and his wife Catherine, Duchess of Cambridge, who are on a royal visit to California from July 8 to July 10, will attend the event. REUTERS

Jennifer Lopez remains a romantic despite her recent split with husband Marc Anthony, but she said finding a way to love herself is what gave her the courage to walk away from the seven-year marriage.

In her first interview since announcing their breakup in July, the actress and singer told Vanity Fair magazine that both she and Anthony had worked hard to keep the marriage alive and that he "will always hold a special place in my heart."

But it was Lopez who apparently decided to end it.

"I'm a hopeless romantic and passionate person when it comes to love," Lopez told the magazine in an interview for its September issue.

"It's not that I didn't love myself before. Sometimes we don't realize that we are compromising ourselves. To understand that a person is not good for you, or that that person is not treating you in the right way, or that he is not doing the right thing for himself if I stay, then I am not doing the right thing for me. I love myself enough to walk away from that now," she added.

The marriage was the third for Lopez, 42, and produced twins Emme and Max in 2008.

But the "On the Floor" singer and "American Idol" judge said she remains "an eternal optimist about love."

"It's still my biggest dream. I am positive -- determined to move forward with my life, bring up my babies, and do the best job I can as a mother, entertainer, and person. I now look forward to new challenges. I feel strong," she said.