Develop a custom global style for links in Laravel 8 using Tailwind CSS

I am struggling with Tailwind CSS and trying to remove the default style for links while adding an underline to all of them.

I attempted:

@layer base {
  a {
    @apply underline;
  }

However, I can't figure out where to place this code. I tried putting it inside a style tag in my layout blade HTML file, but it didn't work.

Another attempt was:

<style>
ul-link{
 @apply underline;
}
</style>

...
<div class="ul-link">Test</div>

This approach also did not work as there was no underline visible.

Surprisingly, using the following structure worked:

<div class="underline">Test</div>

I am puzzled by why @apply is not working and unsure how to create a global style. What could I be missing?

Answer №1

To incorporate these configurations, you must include them in the base layout section of your app.css or app.scss file within your project.

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  a {
    @apply underline;
  }
}

If you prefer not to apply these styles globally, you can assign a class name for this purpose.

.a-line {
    @apply underline;
}

This approach allows you to differentiate between elements:

<a href="#">Text 1</a>

<a href="#" class="a-link">Text 2</a> // will have underline

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Positioning the Logo Responsively Alongside Menus

Currently, I am in the process of mastering responsive designs. This involves creating a website that adapts to different screen sizes efficiently. The layout includes a name logo with two horizontal lines on either side. The logo should be centered at t ...

CSRF token mismatch issue with Laravel across multiple domains

I am in the process of developing a system that utilizes two separate domains, sub1.domain.com and sub2.domain.com. These domains essentially function with the same system, however, I have opted to use two domains for the sake of clarity for the users. Wh ...

The grid expands to cover the entire width of the browser

Hello everyone, I am a newbie when it comes to JavaScript and CSS. I am in need of a code, whether it be JavaScript or CSS, that will allow me to stretch out a grid layout measuring 5 x 2 along with pictures to completely cover the width of the browser wi ...

Is it possible to dynamically convert percentages to pixels in real-time?

I am working on a project with a fluid percentage-based horizontal grid and I want to have the same vertical margins as my horizontal ones. This is the code I have: .block_12_24{ display:inline-block; vertical-align:top; width:48%; margin-right:2%; margi ...

Ways to verify if the CSS background-color is set to white?

I am looking for a solution: $('*').click(function() { if($(this).css("background-color") == "#ffffff") { $(this).css("background-color") == "#000000" } });​​​​ that will execute on click of a specific cla ...

Tips for maintaining the size of child elements within a parent container without affecting the font size in CSS

I have a basic navigation bar setup: <nav> <a href="#">Home</a> <a href="#">About</a> <a href="#">Register</a> </nav> Along with the CSS styling for the navigation and anchor tags: nav { background- ...

Exploring the connection between two divs using onmouseover and onmouseout events in JavaScript

I am currently working on creating a function that displays a button when the mouse hovers over an element and hides it when the mouse is moved away. The example below illustrates my issue: ------------------------------------------------------------ - ...

Div not centered after translation by 50% on the Y-axis

My HTML and body have a height of 100vh. Inside my body, I have a square that is 100px by 100px. When I apply top: 50% to the div, it moves down 50%. But when I apply translateY(50%) to the div, it does not move down 50%. Why is this? Please note that y ...

Issue with Vue components causing dropdowns and modals to malfunction until a page refresh

While working with Vue.js and Laravel 5.4, I have encountered an issue where everything functions correctly in the .blade.php files, but not in the .Vue files. Specifically, nothing occurs when I click on a dropdown or a modal button. Strangely, everythi ...

What is the process for implementing CSS on the header of a Material UI Table with stickyHeader functionality?

I've implemented a Material UI table with the stickyHeader prop to keep the header fixed. However, I'm facing an issue where other CSS styles are not being applied to the header section. const useStyles = makeStyles((theme) => ({ tableHead ...

Having issues with installing laravel-elixir due to node-sass errors

I am relatively new to this platform and I'm currently learning about node.js modules and Laravel (5.1.11) in general, so... My Laravel installation is fresh and was set up using the cPanel Installitron. I am utilizing PHPStorm to install all necessa ...

Tips for creating a more flexible HTML container and resizing the navbar for mobile devices

In my current HTML code, I have 3 "col-md-4" divs within a row, each with a container--wrap to fill the webpage with 3 equally sized containers. These divs are placed inside another div with class = container-fluid. When I resize the window, the containers ...

PHP conditionals

Viewing the webpage www.evolvedtools.org/Genr8PageIntro.php, I have implemented a method to fetch blogs from my wordpress.org blog and display them on this particular page using some simple php markup: In the header of the page: <?php require('. ...

What is the best way to apply background color to match the height of the parent element?

When creating cards, I encounter a challenging issue. I am struggling to fill the background-color of the entire box content as I am new to HTML and CSS and unsure how to achieve this. Below are my codes. .box-container1 { display: flex; justify-con ...

The CSS file fails to load in MVC framework due to a loading issue

I am having trouble accessing the CSS file located in the MVC AREA section of my website. Below is the full path to the CSS file: I believe the path is correct because JavaScript files and images are loading from the same location without any issues. Au ...

Is there a way to decrease the speed of a range slider?

Recently, I created a range slider using HTML, CSS, and JS to complement my Lua Nui. It's been working smoothly for the most part, but I've noticed an issue when sliding too quickly on the slider. As I slide it to the left, certain values fluctua ...

Align elements evenly across the center while maintaining a controlled distance between each one

In my current scenario, I am working with a flexible number of elements ranging from 2 to 5. My goal is to evenly distribute these elements within a div that also has variable width. This task might seem straightforward, but there's a unique twist inv ...

How to keep jQuery horizontal submenu open when clicking on the menu

Seeking assistance with a menu issue. I have a horizontal menu with subitems that display when clicked, but having trouble with the submenu behavior. When clicking on a submenu item, I want it to remain open and show the related items underneath it. For ex ...

Strange glitch in the Trebuchet MS font

I am currently attempting to utilize the jquery.fullcalendar plugin with jQuery UI theming. Everything seems to be functioning properly, except for an issue where the user's selection of a time range (week or day view) is displaced by approximately on ...

Laravel beyondcode websockets experiencing connection issues

I've implemented the Laravel websockets package to create my own websocket server. According to the documentation of the package, here is the configuration I have: .env settings: PUSHER_APP_ID=761772 PUSHER_APP_KEY=qwerty PUSHER_APP_SECRET=secret PU ...