Stylesheet manzilini HTML-kodga qaerga qo'yishim kerak?

Quyidagi muammo bor:
CSS faylida qanday o'zgarishlar qilsam, maqsadli HTML faylga ta'sir qilmaydi Ilgari "index.html" nomi berilgan (Braxets nusxasini qandaydir tarzda yaratgan - men HTML/CSS uchun yangi bo'lganman) va bu o'zgarishlar faqat o'sha sahifada yuz berdi. Stil sahifalarini HTML kodiga qaerda joylashtirishim kerak? bosh tanasi HTML kodi:

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

<!DOCTYPE HTML>
<html>
  <head>
    <title>Acasa</title>
  </head>
  <body background=".\images\colaj.jpg">
      <link rel="stylesheet" href=".\acasa\acasa.css">
       
      
 
    


 
    


</body> </html>
</div> </div> And the CSS:

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    width: 200px;
    background-color: rgb(200,30,30);
    border: 1px solid #555;
}

li a {
    display: block;
    color: rgb(255,255,255);
    padding: 8px 16px;
    text-decoration: none;
}

li { margin: auto;font-family: "Arial Black", Gadget, sans-serif;
    text-align: center;
    border-bottom: 1px solid #555;
}

li:last-child {
    border-bottom: none;
}

li a.active {
    background-color: rgb(128,128,128);
    color: white;
}

li a:hover:not(.active) {
    background-color: #555;
    color: white;
}
</div> </div>

Qanaqa muammo? Uzoq kod uchun uzr so'raymiz. Iltimos, qanday xatoga yo'l qo'yganimni ayting, men bunga butunlay yangiman.

0
Buni bosh yorlig'i ichiga qo'ying
qo'shib qo'ydi muallif Omprakash Arumugam, manba

8 javoblar

Buni sarlavhasi bo'limiga qo'ying:

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

Mana mening sahifalarimdan to'liq sarlavhaning misoli:

<head>
    <title>My Page</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
1
qo'shib qo'ydi

Ichki uslubni ishlatmoqchi bo'lsangiz, CSS-ni bosh ichidagi

blokiga qo'yishingiz mumkin. Biriktirilgan kodga qarang.

I would however suggest you to go through the MDN How CSS works page and go through the basics. Also check how CSS can be imported via Internal stylesheets, External stylesheets & Inline stylesheets.

<!DOCTYPE HTML>
<html>

  <head>

    <title>Acasa</title>
    
  </head>

  <body background=".\images\colaj.jpg">
    <link rel="stylesheet" href=".\acasa\acasa.css">
    
    

 

    



    




</body> </html>
0
qo'shib qo'ydi

For your specific question, I agree with the other answers. Include CSS in <head>...</head>.

Biroq, brauzeringizga qarab sizning asosiy muammo sizning yo'llaringizdagi teskari tomondan foydalanayotgan bo'lishi mumkin. Oldinga tirnoqlardan foydalaning. Uslub varag'ini ./ acasa/acasa.css deb nomlashni harakat qilib ko'ring (CSS fayli aslida HTML fayli joylashgan joyga nisbatan acasa pastki katalogida joylashgan deb taxmin qilinsa).

0
qo'shib qo'ydi

Har doim CSS-ni sahifaning boshiga qo'ying

0
qo'shib qo'ydi

Quyidagi kabi bosh yorlig'i ichida:

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

<head>
  </head>
</div> </div>

0
qo'shib qo'ydi

Siz tashqi CSS-fayllardan foydalangandan buyon har doim HTML-sahifaning qismida bo'lishi kerak. Iltimos, https://www.w3schools.com/css/css_howto.asp ga qarang. Qo'shimcha ma'lumot olish uchun.

0
qo'shib qo'ydi
<!DOCTYPE HTML>
<html>
<head>

<title>Title of the document</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content=""/>
<meta name="author" content=""/>

<link rel="shortcut icon" href=""/>
<link href="yourcssfile.css"  rel="stylesheet" type="text/css"/>
<!--or you can add directly here CSS codes  -->
<script src="yourscriptfile.js" type="text/javascript"></script>
<!--if you want you can put the script files 
before </body> tag for the site to be fast  -->

</head>

<body>
  The content of the document......
</body>

</html>

and you can look this site for learn about first html and CSS notes

0
qo'shib qo'ydi

Bu kodlash muammo bo'lmasligi mumkin. Ehtimol, veb-brauzeringiz doimo kompyuterni qayta ishlamaydi

Menga Opera bilan juda ko'p narsa keladi, odatda ctrl + f5 bilan qayta ishlanadi.

0
qo'shib qo'ydi