Can i put css codes inside the <body> tag | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can i put css codes inside the <body> tag

pliss tell.. or do i have to write it down on a seperate file and then link them together

9th Jan 2017, 4:26 PM
stephen haokip
stephen haokip - avatar
8 Answers
+ 8
<style>css</style>
9th Jan 2017, 4:27 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 6
Yes.
9th Jan 2017, 4:30 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
style and link tags belong in the document head. <!DOCTYPE html> <html> <head> <!-- css or link (included css) here--> </head> <body>..... You can use style attributes on most elements, however it is best practice to just use CSS/Javascript for this tying into custom attributes or class/id attributes.
9th Jan 2017, 4:30 PM
Louis Milotte
Louis Milotte - avatar
+ 2
thank you bro... you mean i can put my css code inside the style tags.. right
9th Jan 2017, 4:29 PM
stephen haokip
stephen haokip - avatar
+ 2
To add on to Zainab answer, you can import your external CSS file to link to your html using the following syntax: <head> <link rel="stylesheet" type="text/css" href="pathToYourCssFile.css"/> </head> The 2 other styling via inline and embed is as explained.
9th Jan 2017, 4:48 PM
Alex Soh Chye Wat
Alex Soh Chye Wat - avatar
+ 1
besides can i put the style tags inside the body tags
9th Jan 2017, 4:32 PM
stephen haokip
stephen haokip - avatar
+ 1
You can put as many <style></style> you want, and anywhere inside <html></html> ( with common restrictions for valid Xml ^^ )...
9th Jan 2017, 5:47 PM
visph
visph - avatar
0
Hi, There's 3 ways of styling HTML: 1. Inline CSS 2. Embed in the HTML file 3. External CSS.. 1. Inline css looks like this: <p style="color:red;"> Red paragraph</p> 2. Embed CSS: <style> p{ color: red; } </style> 3. External, (in a separate file linked to HTML) p{ color: red; }
9th Jan 2017, 4:31 PM
Zainab