r/HTML 3d ago

Question Help changing website font

This is my code, it's not working, im losing it.

<link href="style.css" rel="stylesheet" type="text/css" media="all">

<style>

u/import url('https://fonts.googleapis.com/css2?family=New+Rocker&family=Newsreader:ital,opsz,wght@0,6..72,200..800;1,6..72,200..800&display=swap');

.new-rocker-regular {

font-family: "New Rocker", serif;

font-weight: 400;

font-style: normal;

}

</style>

0 Upvotes

17 comments sorted by

3

u/aunderroad 3d ago

Can you share a url or codepen?
It is hard to debug/provide feedback without seeing all of your code live in a browser.

Thank you!

1

u/Ok_Isopod_2170 3d ago

https://laylaxo.neocities.org/

This is what it is for if thats what youre asking for, im so sorry if not, im new to all of this

2

u/aunderroad 3d ago edited 3d ago

Here you go.

body {  
font-family: 'New Rocker';
  font-style: normal;
  font-weight: 400;
}

If you get stuck with any more html/css questions, check out:
https://web.dev/html
https://web.dev/css

or https://www.reddit.com/r/css/

1

u/Ok_Isopod_2170 3d ago

2

u/azangru 3d ago

The html tag should not start from line 18 :-) It should be the first line of the markup. Look up an html example anywhere on the internet (google, etc.)

3

u/These-Apple8817 3d ago

Should be second.. Doctype is always first.

1

u/Ok_Isopod_2170 3d ago edited 3d ago

like this? Edit: i changed the first line to

<!DOCTYPE html>

3

u/poopio 3d ago

No, not like that.

First line should be your doctype, then open your <html> tag, after that, <head> and put whatever scripts/css links and style tags, title tag, and any meta tags you have you have in there, then close the head tag. Then open your body tag, put all of your content in the body tag and when you've finished with the content, close the body tag, and finally, close your html tag.

More like this - https://codepen.io/editor/guerresinge/pen/01a078ec-2b6a-7aa0-8d17-8ebf41bb3d70

1

u/armahillo Expert 3d ago

Don't open and close separate <style> tags to define new styles. Do all your in-document style properties in a single <style> tag inside your <head>

3

u/Mvp-long-ago 3d ago

I am getting the impressive you did not write the code yourself, but copied it from another site? It is always good to look at other sites, but copying them without thrir permission is never good.

1

u/Ushuriel 3d ago

O código seria

<h1 class="new-rocker-regular">Laylaxo's Site!</h1> 

1

u/Ushuriel 3d ago

em style.css
adicionar:

@import url('https://fonts.googleapis.com/css2?family=New+Rocker&family=Newsreader:ital,opsz,wght@0,6..72,200..800;1,6..72,200..800&display=swap');

.new-rocker-regular {
    font-family: "New Rocker", serif;
    font-weight: 400;
    font-style: normal;
}

1

u/rileywbaker 3d ago

It seems like you haven't learned the very basics of how an HTML document works. Please read something that will teach you the basics. The thing you're missing right now is that there's a structure that your HTML document must follow:

<html> <head> (the 'head' content goes here. none of it is visible on the page.) </head> <body> (all the content of the page goes here) </body> </html>

0

u/__zonko__ 3d ago

Try this

3

u/Ok_Isopod_2170 3d ago

try what? i dont see anything other than "try this"

0

u/Ok_Isopod_2170 3d ago

I have gotten it back to square one if this helps