educative.io

Educative

Html and css connection

how to link html and css on sublime

Hi @SHATANSHU_AGARWAL,

This is Fatimah Abdullah from Educative.

In regards to your question, we can link an HTML and CSS file using the <link> tag in the HTML file and providing the path to the CSS file in the href attribute. It would be no different if you are using any kind of code editors other than sublime too, this works in every case.
Example:

home.html:

<!DOCTYPE html>
<html lang = "en-US">
 <head>
  <meta charset = "UTF-8">
  <title>Demo Page</title>
  <link rel = "stylesheet" type = "text/css" href = "myStyle.css" /> 
 </head>

 <body>
  <h1>hello world!</h1>
 </body>
</html>

myStyle.css:

body {
 background-color: #B1A9D4;

}
h1 {
 color:#45597E;
 text-align: center;
}

I hope this helps!

Best Regards,
Fatimah Abdullah | Developer Advocate
Educative