skip to Main Content

I tried to link a css to html in laravel and link an image (both css and image are in public folder) but it does not work. I tried using asset and url but it does not work either. I don’t understand what is wrong. This is how I wrote the link:

<link rel="stylesheet" href="/css/styles.css">

<img src="/img/logo-kitsune-dojo.jpg" alt="logo kitsune dojo">

I have already tried asset and url. They don’t work. I want mi css and my imagen to link.

2

Answers


  1. use asset() function generates a URL

    <link rel="stylesheet" type="text/css" href="{{ asset('css/styles.css') }}">
    
    <img src="{{ asset('img/logo-kitsune-dojo.jpg') }}" alt="logo kitsune dojo">
    
    Login or Signup to reply.
  2. You may solve this problem by using asset() helper function

    For css link: If your css exist in public folder folowing this directory you may use this

    For Image: If your image exist in public folder folowing this directory you may use this

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search