Generally, yes it’s easier to paint your skirting boards before your walls. Painting the woodwork first allows you to work more freely and means you don't have to worry as much about getting paint onto freshly painted walls.
Once the skirting board paint has dried, you can paint the walls and cut in neatly along the top edge of the skirting. If you're also painting doors, frames or other woodwork, it's usually best to complete these before painting the walls.
For the best finish, prepare and prime the skirting boards where required, apply your chosen woodwork paint, and allow it to dry fully before decorating the walls. Using masking tape or a quality cutting-in brush can help achieve a clean line between the wall and skirting.