Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add CSS in Laravel 8

Tags:

css

laravel-8

I put my CSS file inside public/css folder. I added CSS file in head section like below.

<link href="{{ url('/css/app.css') }}" rel="stylesheet">

But CSS is not working.

like image 682
abu abu Avatar asked Nov 01 '20 11:11

abu abu


People also ask

Where do I put CSS files in Laravel?

this folder css or whatever you named it, must be placed inside your public folder. Show activity on this post. Search for Public folder in Laravel. Create css folder (that contains stylesheet files of your project), javascript and Images folder (contains images that you will use in your project).

How to update HTML code in Laravel using blade?

Search for Public folder in Laravel. Create css folder (that contains stylesheet files of your project), javascript and Images folder (contains images that you will use in your project). Go to layouts in app.blade.php file update html code using blade syntax:

What is Laravel Mix and how to use it?

As with CSS, we may use Laravel Mix to easily compile JavaScript components into a single, browser-ready JavaScript file.

How do I build a JavaScript application in Laravel?

By default, the Laravel package.json file includes a few packages such as lodash and axios to help you get started building your JavaScript application. Feel free to add or remove from the package.json file as needed for your own application. Once the packages are installed, you can use the npm run dev command to compile your assets.


2 Answers

In Laravel 8, make sure your files are in the public folder and reference them like this:

<link rel="stylesheet" type="text/css" href="{{ url('css/app.css') }}">
like image 70
NerdyGinger Avatar answered Oct 10 '22 01:10

NerdyGinger


This is working for me in Laravel 8 (make sure your files are in the public folder)

<link href="{{ asset('css/app.css') }}" rel="stylesheet">
like image 4
Mak Alamin Avatar answered Oct 10 '22 02:10

Mak Alamin