description
it is used to import the contents of the less or css files.
example
the following example demonstrates the use of importing in the less file −
<html>
<head>
<title>less importing</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<h1>example using importing</h1>
<p class = "myclass">less enables customizable,
manageable and reusable style sheet for web site.</p>
<p class = "myclass1">it allows reusing css code and
writing less code with same semantics.</p>
<p class = "myclass2">less supports creating cleaner,
cross-browser friendly css faster and easier.</p>
</body>
</html>
now create the myfile.less file.
myfile.less
.myclass {
color: #ff8000;
}
.myclass1 {
color: #5882fa;
}
now create the style.less file.
style.less
@import "http://www.tutorialspoint.com/less/myfile.less";
.myclass2 {
color: #ff0000;
}
the myfile.less file which will be imported into style.less from the path https://www.tutorialspoint.com/less/myfile.less
you can compile the style.less file to style.css by using the following command −
lessc style.less style.css
execute the above command; it will create the style.css file automatically with the following code −
style.css
.myclass {
color: #ff8000;
}
.myclass1 {
color: #5882fa;
}
.myclass2 {
color: #ff0000;
}
output
follow these steps to see how the above code works −
save the above html code in the importing.html file.
open this html file in a browser, the following output will get displayed.