Forum Discussion
How to inject css / java script in Modern page in one of the Sub site SharePoint online?
Hi VISKR05;
the recommended way to apply css and javascript customizations to a modern site would be SharePoint Framework (spfx)
https://learn.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-framework-overview
https://www.youtube.com/watch?v=6WTtjXP5yW4
You can create custom webparts with that or create an application customizer that registers itself on every page of your site. You can even register custom commands to a list with a custom listview commandset
https://learn.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/building-simple-cmdset-with-dialog-api
But if you just want to style a list then you could use SharePoint json List formatting. You just create a JSON file that specifies how a column or row should be rendered and apply that
https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting
What you can do with that is quite impressive
https://pnp.github.io/List-Formatting/viewsamples/
Or you install the modern script editor webpart (itself an spfx solution)
https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-script-editor
But keep in mind that this is the cloud.... The HTML structure of the modern ui itself might change every day.
The last way might be the fastest way to fix your problem, but the first and second way conform more to the modern ui development standard.
Best Regards,
Sven