How to embed css to html in laravel?


by ryleigh , in category: PHP Frameworks , 6 months ago

How to embed css to html in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer


by mac , 6 months ago


In Laravel, you can embed CSS to HTML by following these steps:

  1. First, open the resources iewsyour-file-name.blade.php file where you want to embed CSS.
  2. Inside the HTML file, you can include the CSS file by using the asset() helper function. This function generates the URL for the given asset file. For example, to include a CSS file located in the publiccss directory, you can use the following code:
<link rel="stylesheet" type="text/css" href="{{ asset('css/your-css-file.css') }}">

Make sure that the path provided is correct and matches the actual location of your CSS file.

  1. Alternatively, you can use the asset() function to generate the URL for an inline CSS style. For example:
    .your-class-name {
        color: red;

  1. Once you have embedded the CSS file or added the inline styles, save the file and the CSS will be applied to your HTML page.

Note: Make sure that the CSS file is located in the correct directory and the file name is spelled correctly. Also, remember to compile and cache your assets if you have made changes to the CSS file.