Font-family does not work on my page

2

I have decided to use the google source "Raleway" with which I have added this to my code:

<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">

And this in my css:

html, body {
height:100%;
width:100%;
font-family: 'Raleway', sans-serif !important;
}

But it does not work. It also does not work with conventional sources that are not google.

I've tried putting !important and without, but it does not work in any way (I've put it in the body and html because I want that source on the whole page).

    
asked by Pavlo B. 25.10.2016 в 17:32
source

3 answers

2

It works well as your colleagues have told you. Just refer to your stylesheet by putting:

 <!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="tu-ruta-a/styles.css">
</head>
<body>
...
</body>
</html>

Or just putting that part directly, although it is not advisable:

 <!DOCTYPE html>
<html>
<head>
<style>
    html, body {
      height:100%;
      width:100%;
      font-family: 'Raleway', sans-serif !important;
    }
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>
    
answered by 25.10.2016 / 18:17
source
3

It seems that the error that does not go the CSS is that you do not have it well linked to your html. For this, in your html you will have to use the following:

<link rel="stylesheet" type="text/css" href="estilos.css">

in href you will have to indicate the path of your file CSS taking as reference your file html .

You can use absolute paths or relative routes, however, I recommend that you do not use absolute routes (example: C://ruta/ruta/estilos.css ) and use relative routes since if you move your project to another computer, the routes may no longer work.

Using relative routes and taking as reference your html file, imagine the following structure:

|
|---css
|      |
|      |--- estilos.css
|
|------html

You should use <link rel="stylesheet" type="text/css" href="css/estilos.css"> .

In contrast to this other route:

|---css
|      |
|      |--- estilos.css
|
|---vistashtml
       |
       |--- pagina.html

You should use <link rel="stylesheet" type="text/css" href="../css/estilos.css"> .

With the colon ../ you indicate that you have uploaded to the parent directory of the directory you are in.

I hope this solves your problem.

    
answered by 25.10.2016 в 18:14
0

may sound trivial my answer but sometimes instead of

<link rel="stylesheet" type="text/css" href="../css/estilos.css">

goes

<link rel="stylesheet" type="text/css" href="../css/estilos.css"/>
    
answered by 27.10.2016 в 20:31