For a team of junior web developers, who are very motivated to improve their skills, and applying their new knowledge to the development has produced great results so far. But I am conscious of the time they would be spending on learning during their work hours. What is the ideal balance of allocating them a number of hours for online training/courses in a week so much that it does not affect their deadlines.
...has produced great results so far.
Sounds promising! I can think of several approaches to managing skills improvement / professional development in the context of scrum:
Arguably, professional development could be considered "all part of the day's work" which is supposed to go on during a sprint. If you're figuring sprint capacity supposing that, say, 30-40% of the workday is devoted to such routine tasks, then perhaps they could spend up to 10-20% on learning. (Adjust numbers for your actual situation of course.)
If your team is not continuously sprinting, time between sprints could be used.
If your team can afford to cycle one developer at a time off the sprints, that developer could spend their time on a combination of skills improvement and tech debt. Note that some teams routinely keep one team member out of sprint to be available to squash bugs or deal with other urgent problems, eg Batman: this model could be combined with learning time.
If there is a specific area or technology that the team either anticipates needing, or has identified as an area that needs improvement (eg in retrospectives), and if your PO is onboard with the idea that such learning would be a good investment, you could devote a sprint to this, with an appropriate sprint goal.
If the difficulty is persuading the PO and/or other stakeholders that the learning is a good investment, I would suggest making two points:
professional development is a good investment in junior developers; it's how they become senior developers who can be more productive and/or bill at a higher rate. It also keeps morale high, as you have already alluded to in your question.
presumably your "great results so far" mean improved productivity or quality, ie higher velocity or smaller bug count. Pull out those numbers! and negotiate with your stakeholders about how much time to invest for the kind of return you are getting or can reasonably project.
Also, some companies have policies about continuing professional development, and it's included in their staffing plans: eg, 1 FTE turns into 0.8 FTE after sick time, vacation time, & prof dev are taken into account. Check with your line manager and/or HR dept to see if that's true in your case. If so, then treat learning time like any other time off.
Good luck! And good for you for trying to grow your team's skills.
As you put Scrum tag I will answer from the Scrum point of view.
The team should spend as much time for learning as they think it is necessary to produce product increment every sprint according to the definition of done.
As long as Product Owner (PO) is happy with team progress I cannot see any reason to influence the team's training time. If the PO would think that the less learning would increase team's velocity (in a long term) he/she can discuss this with the team - to what point the education helps the project and to what point it is not necessary or the training scope is outside of the required skills.
When discussing a sprint goal the team should be aware of how much would they need to spend on education to finish the Sprint backlog. Here is the best time to address the issue. If the learning is not strictly connected to the sprint goal, it should be discussed how this learning can increase teams effectiveness in long run.
Kanban offers a great way to handle continuous improvement. You just need to introduce slack in the system. A developer can pick up work from the continuous improvement board whenever they're blocked.
Since this is a PM forum, I think this is an easy answer. The answer is zero. A customer should not have to pay for one hour of learning. People will learn as a side effect of doing the work but every hour they work needs to provide value to the project, not the other way around. The only caveat to that is training within that specific project context, i.e., training to handle project-specific processes and procedures, rules, specific tool sets, etc. Otherwise, those people on the project need to be ready to go if they are charging for those hours. If a seller of work needs to train their people, they can put them on a project but those hours worked do not get billed.
Like a teaching hospital. A patient or his insurance company will not get billed for the fifteen physicians doing rounds.
One more caveat: If the customer is requiring the use of a brand new technology that is not well known in industry, then a seller can negotiate training as part of its work proposal. That would be reasonable but also pre-negotiated.
EDIT: This applies to in-house, too. In-house project workers are building something for an in-house customer. In-house projects cost money, too. Any training taking place, whether it is a buyer-seller situation or in-house, it is NOT part of the project but part of the overhead, including the seller's overhead.
For those that had such heartburn with my answer, let's bring it home. Say you hired a landscaping company T&M (hourly) to get your yard ready for summer. Two hours in, you look out and see all eight sitting in a circle on your lawn being taught about different types of soil and which is more conducive for different types of flowers, taking up two hours. After a total of eight hours, they finish and you get a bill for eight hours x each employee. Would you pay it? If so, I would like to sell you some lawn services.