Search code examples
htmlcssfontsfigma

incorrect text format from showing in html/css from figma


In Figma, I have a design for text that shows the following code:

/* Create Account */


position: absolute;
width: 343px;
height: 142px;
left: 575px;
top: 272px;

font-family: Montserrat;
font-style: normal;
font-weight: bold;
font-size: 30px;
line-height: 37px;
display: flex;
align-items: center;
text-align: center;

color: rgba(255, 255, 255, 0.92);

However, when I have the following code in html (with the text having the same font as indicated by Figma, the font of the text appears different in html/css than it does in figma as indicated by the two images I've attached (please ignore the differing backgrounds):

<!DOCTYPE html>
<html lang="en">

<head>

</head>

<body style="margin: 0 auto;text-align:center;background: #141E30;  /* fallback for old browsers */ background: -webkit-linear-gradient(to bottom, #243B55, #141E30);  /* Chrome 10-25, Safari 5.1-6 */ background: linear-gradient(to bottom, #243B55, #141E30); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */;">

    <p style="font-family: Montserrat; font-style: normal; font-weight: bold; color: rgba(255, 255, 255, 0.92);font-size: 30px;">Create Account</p>

</body>

</html>

Would anyone know why I can't recreate the exact same font appearance in html/css?

Figma Design: Figma Appearance HTML/CSS: HTML/CSS appearance


Solution

  • Add in HTML head:

    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;600;700;800&display=swap" rel="stylesheet">
    

    Add in Css:

    font-family: 'Montserrat', sans-serif;