2

I want to apply margin-bottom on #createNewBook, I added a CSS file in laravel by using <link rel="stylesheet" href="/assets/css/style.css">. But it's not working. Can anyone tell me how to add a CSS file to my laravel project?

This is my HTML code in laravel: enter image description here

This is CSS code: enter image description here

This is my directory format:

enter image description here

And this is the output:

enter image description here

4
  • 1
    only things in the public folder are accessible publicly (served by the webserver) ... nothing below that folder is directly accessible ... so you have to put assets in the public folder some where ... the public folder is the root of your site Commented May 27, 2022 at 16:57
  • okay, let me check. Commented May 27, 2022 at 16:59
  • @lagbox it's not working Commented May 27, 2022 at 17:01
  • Please take a look at the official Laravel Mix documentation on how to compile assets. There you will find all the information you need. laravel.com/docs/9.x/mix#main-content Commented May 27, 2022 at 17:04

2 Answers 2

7

Put the assets folder in public then in the blade file use this syntax to load css

{{asset('assets/css/style.css')}}
Sign up to request clarification or add additional context in comments.

1 Comment

@MubeenAhmad Consider marking the answer as the correct one to help others having the same trouble.
3

You have to put your assets folder into the public folder because only the things in the public folder are accessible publicly.

enter image description here

And then in the blade.php file use the following syntax to load CSS.

<link rel="stylesheet" href="{{asset('assets/css/style.css')}}">

1 Comment

but after 'npm run build' I got 'public/build/assets/app.222e333.css' how I can include this one? laravel 9.X

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.