Succession to the British throne is determined by descent, gender (for people born before October 2011), legitimacy, and religion. Under common law, the Crown is inherited by a sovereign's children or by a childless sovereign's nearest collateral line. The Bill of Rights 1689 and the Act of Settlement 1701, restrict succession to the throne to the legitimate Protestant descendants of Sophia of Hanover that are in "communion with the Church of England".
Spouses of Roman Catholics were disqualified from 1689 until the law was amended in 2015. Protestant descendants of those excluded for being Roman Catholics are eligible.
Before 2011 the sons of the monarch and their children were before older daughters of the monarc in the line of succession. This the reason why Princess Anne, (though born before her younger brothers) The Princess Royal is no 13 in the present line of succession.
The Act of Settlement (1701) laid down that only Protestant heirs of Princess Sophia, granddaughter of James I, may succeed to the British throne. Neither Roman Catholics, nor those who marry a Roman Catholic, nor those born out of wedlock, may remain in the line of succession. Under common law the crown was passed on by male primogeniture under which younger sons succeed before their elder sisters.
This changed on the 26 March 2015 with the introduction of the Succession to the Crown Bill 2013 which changed the succession laws so that the right of male primogeniture no longer applies. Males born after 20 October 2011 no longer precede their elder sisters in the line of succession. The Duke and Duchess of Cambridge's first child born on 22 July 2013 was a boy Prince George. Their second child Princess Charlotte was born on 2 May 2015. She is 4th in line and will not lose her position even if she has a younger brother.
The Bill removed the disqualification of those who marry Roman Catholics so that George Windsor, Earl of St Andrews, who married a Catholic in 1988 was restored in 35th place after the Duke of Kent. It also repealed the Royal Marriages Act 1772 so that only the first 6 persons in line to the throne require the Sovereign's approval to marry. This means that Princess Beatrice and Princess Eugenie no longer require permission from the Queen to marry.