linking custom CSS in flask

  1. Create a "static" folder in your Flask project directory.

  2. Inside the "static" folder, create a "css" subfolder.

  3. Place your custom CSS file (e.g., "style.css") inside the "css" subfolder.

  4. In your Flask template (HTML file), use the url_for function to generate the correct URL for the static file. Import the url_for function at the top of your HTML file if not already imported.



Ensure that the url_for argument corresponds to the structure of your "static" folder.

  1. Run your Flask application, and the custom CSS file should be linked and applied to the HTML templates.

Note: Make sure that the Flask app is structured appropriately, with the "static" folder at the top level, and the CSS file within the "css" subfolder. The url_for function is used to generate the correct URL for static files, ensuring that they are served correctly when the application is run.