If you have any query feel free to chat us!
Happy Coding! Happy Learning!
To style our app, we can add CSS to our HTML files. We can either write CSS directly in the HTML file or link an external CSS file. Linking an external CSS file is a more organized approach and makes it easier to make changes in the styling.
Here's how to link an external CSS file to our Express app:
public
in our project directory. This is where we will keep all our static files, including CSS, images, and client-side JavaScript files.public
folder, create another folder named css
.style.css
inside the css
folder. This is where we will write our CSS code.style.css
file and add some CSS code. For example, we can set the background color of the body to blue:cssCopy code
body {
background-color: blue;
}
app.use(express.urlencoded({ extended: true }))
line:javascriptCopy code
app.use(express.static(__dirname + '/public'));
This tells Express to serve static files from the public
directory. The __dirname
variable contains the absolute path of the current directory.
<head>
tag:htmlCopy code
<link rel="stylesheet" type="text/css" href="/css/style.css">
This tells the browser to load the style.css
file from the css
folder inside the public
folder.
We can add more CSS rules to our style.css
file to style other elements in our HTML file.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.