On to CSS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

On to CSS

When doing CSS, does codes have to be written in both HTML and CSS?

16th Mar 2020, 2:42 PM
Tyler Eavey
Tyler Eavey - avatar
13 Answers
+ 4
Tyler Eavey In that code, your CSS is not taking effect. You have this: body{ p.fantasy font-family:Blippo,fantasy; } _____________________________ Instead put it like this: body{ } p.fantasy { font-family:Blippo,fantasy; } You dpn’t need to wrap the other elements inside body{} in css. each element get their own. example: body { ... } .container { ... } main { ... }
16th Mar 2020, 3:20 PM
Ginfio
Ginfio - avatar
+ 5
Tyler Eavey In that code, you're using wrong property font-family property is used to change font type like Arial or Sans etc. You have to use font-style property in order to make text italic.
16th Mar 2020, 3:12 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 4
CSS classes are applied to html tags. So technically yes, to see CSS codes' effect you should have HTML.
16th Mar 2020, 2:57 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
Tyler Eavey “italic” is not font-family. That’s a font-style. So ... to accomplish the italic effect, you would use... font-style: italic
16th Mar 2020, 3:13 PM
Ginfio
Ginfio - avatar
+ 1
I am having so much trouble with the CSS code changing the look of my website. Example: <p class="italic">I am cool.</p> CSS: p.italic{ font-family:italic; } Would this be wrong?
16th Mar 2020, 3:04 PM
Tyler Eavey
Tyler Eavey - avatar
+ 1
yeah. The CSS will style the HTML. So if there is no html there’s nothing to style.
16th Mar 2020, 3:05 PM
Ginfio
Ginfio - avatar
+ 1
Tyler Eavey it should be p.italic{ font-style: italic; }
16th Mar 2020, 3:11 PM
Ore
Ore - avatar
16th Mar 2020, 3:15 PM
Tyler Eavey
Tyler Eavey - avatar
+ 1
How would I section it off so I can have different fonts across the page?
16th Mar 2020, 3:20 PM
Tyler Eavey
Tyler Eavey - avatar
+ 1
1. A quick fix https://code.sololearn.com/WtP1lmWmu39r/?ref=app 2. Explanation Apart from what Ginfio and others has pointed out, your code still has one improvements and two mistakes. (The line number below refers to line number in my fix for you) Comment 1 (CSS line 7) .fantasy, no need p Comment 2 (CSS line 14) blippo is local machine font, do not use it, use google fonts instead Comment 3 (HTML line 18) Link to Google Fonts style sheets https://fonts.google.com/ Comment 4 (HTML line 8) <head> is not for content!!!!!! All content must be in <body> <head> is for meta content for browsers and search engine.
16th Mar 2020, 3:35 PM
Gordon
Gordon - avatar
0
Can you look at my code?
16th Mar 2020, 3:09 PM
Tyler Eavey
Tyler Eavey - avatar
0
Cause I don't what you mean.
16th Mar 2020, 3:12 PM
Tyler Eavey
Tyler Eavey - avatar
0
Tyler Eavey to put them in sections, .. wait , first what are your sections going to be? btw, the font for the valuable lessons will work if you took the p.fantasy out of the body {} https://code.sololearn.com/W0tfYw7wLI9N/?ref=app
16th Mar 2020, 3:27 PM
Ginfio
Ginfio - avatar