Where should I access the DOM elements?

You have to access the DOM elements in OnAfterRender or OnAfterRenderAsync of the Blazor component lifecycle. [JS Helper] [Razor] Have a look at the Blazor component lifecycle for more information.

How do you handle 404 pages in Blazor?

The NotFound template section in the App.razor can be used to handling 404 pages. The router shows this content if it hits a route that is not available, which is a 404 page. Create a component Page/Error.razor to display the 404 contents. For more information, read about Blazor routing.