im using appserver and i want to link style.css
.header {
height: "40px";
background-color: "red"
}
in my index.php
<html>
<head>
<META HTTP-EQUIV="Content-language" CONTENT="ar">
<link rel="shortcut icon" href="img/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="CSS/style.css"/>
<title>بام للسيارات | تبضع اينما كنت</title>
</head>
<body>
<div class="header">
</div>
</body>
</html>
but it didnt work i dont know why can someone help me
Obviously your CSS is incorrect,
.header {
height: "40px";
background-color: "red"
}
Noticing the quotes in your values, which are invalid in CSS syntax. It should be,
.header {
height: 40px;
background-color: red;
}
After reviewing your code, there is no other coding errors. But your have serious errors with your file encodings.
index.php was encoded in UTF-16LE, and your didn't declare your charset in the <head> section nor the BOM (neither does your css file, which is encoded in UTF-8). So the browser guesses the resource files are also encoded in UTF-16LE, which read two bytes as one character. So your CSS became totally meaningless to the CSS parser, as it reads 栮慥敤ൻ †栠楥桧㩴㐠瀰㭸††慢正牧畯摮挭汯牯›敲㭤ൽ.
So the fix is pretty straight forward,
Add charset declaration at the begining of your <head>
Save your index.php as UTF-8 encoding or add charset="utf-8" to <link>.
Use this
<html>
<head>
<META HTTP-EQUIV="Content-language" CONTENT="ar">
<link rel="shortcut icon" href="img/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="CSS/style.css"/>
<title>بام للسيارات | تبضع اينما كنت</title>
</head>
<body>
<div class="header">
</div>
</body>
</html>
I have packed your code ger it from here
Related
While trying to access pages from folder my url keeps stacking one after another rather than going to appropriate page.
This is my directory structure.
Website/
css/
js/
includes/
header.php
footer.php
helper.php
sub-folder/
foo.php
index.php
after going to localhost/sub-folder/foo.php it goes to localhost/website/sub-folder/foo.php/index.php instead of localhost/website/index.php
This causes error even when loading css from foo.php which connects via header.php
This is my header.php
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chili Pili</title>
<!-- Bootstrap CSS only -->
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> -->
<link rel="stylesheet" href="css/imagehover.min.css">
<link rel="stylesheet" href="owlcarousel/owl.carousel.min.css">
<link rel="stylesheet" href="owlcarousel/owl.theme.default.min.css">
<link rel="stylesheet" href="css/style.css"></link>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- Custom CSS file -->
<link rel="stylesheet" href="css/utils.css"></link>
<link rel="stylesheet" href="css/responsive.css"></link>
<style>
li{
font-size:20px;
}
.navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover .dropdown-menu .dropdown-item:hover {
color: var(--color1) !important;
}
.active{
color: var(--color1) !important;
border-bottom:2px solid var(--color1);
border-width:20%;
text-align:center;
}
</style>
</head>
<body>
foo.php
<?php
include '../includes/header.php'
?>
<?php
include 'includes/footer.php'
?>
What can be done so urls don't keep stacking and return correct url so css file can be accessed from foo.php. Currently due to stacking its impossible to retrieve css files
In header.php <link rel="stylesheet" href="css/imagehover.min.css"> will link file header.php/css/imagehover.min.css.
try to add a / in front of css like so <link rel="stylesheet" href="/website/css/imagehover.min.css">
I'm trying to add custom styles to navigation and body but the styles aren't showing in my home page but it's showing in another page I'm not getting it any one can help me out with solution where I'm messing around
index.php
<?php include 'include/css.php';?>
<?php $page = 'home';include 'include/navbar.php';?>
<?php include 'include/scripts.php';?>
Screenshot of browser for index.php
css.php
<html lang="en">
<head>
<title>Bootstrap 4 Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" >
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
Screenshot of browser for /include/css.php
style.css
body{
background-color: aqua;!important
}
.navbar-nav > li > a {
color: #ffffff;
}
i am attaching github link please download files upload in your local server and
kindly find the error
you can download files here
Try this one.
body{
background-color: aqua !important;
}
.navbar-nav a {
color: #ffffff !important;
}
maybe you have a path issue for <link rel="stylesheet" href="../css/style.css">
check your directory for home page and other pages.
In base.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Base</title>
<style>
body {
background: blue;
}
</style>
</head>
<body>
<h1>Base</h1>
</body>
</html>
the background of <body> is blue.
But if the CSS is linked, like
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Base</title>
<link rel="stylesheet" href="http://localhost/exp/mysite/css/style.css" type="text/css">
</head>
<body>
<h1>Base</h1>
</body>
</html>
with CSS in http://localhost/exp/mysite/css/style.css
body {
background: blue;
}
it doesn't work. Why?
Can you check error and write text of error for your post? To do that, open Developer Tools, reload page, and when style.css will be red, copy and paste code of Error and text of answer from the server.
I think here may be few common problems:
localhost follows to your computer/server, but web server (Apache / Nginx) doesn't know where your link (http://localhost) should follows. I mean to which directory where css file located.
Second common problem is permissions. For example directory with your CSS or css file has not readable permissions.
There can be few more problems, like CSP or something more complicated, but i need more information from you.
Try to use a relative filepath, this will also make the transfer to a production server easier:
<link rel="stylesheet" href="css/style.css" type="text/css">
instead of
<link rel="stylesheet" href="http://localhost/exp/mysite/css/style.css" type="text/css">
(of course it depends where your html or php document is placed in the file system – if that's in a folder, it will be something like href="../css/style.css"
You should link the css this way
<link rel="stylesheet" href="css/style.css" type="text/css">
or link the css file the exact folder name
Set your folder is:
mysite/index.html
mysite/css/style.css
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Base</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<h1>Base</h1>
</body>
</html>
The problem was
SetHandler application/x-httpd-php
in the .htaccess file.
I've looked all over for a solution but the external link for "gencustomfont" will not work, yes everything is named correctly. Though if I put the bare code in it will, but I'd feel better if it was less cluttered once I officially start adding styles. I'm using c panel.
MAIN
echo '<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet" media="screen">
<link href="css/gencustomfont.css" type="text/css" rel="stylesheet" media="screen">
</head>
<body>
<h1>We are making magic!</h1>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>';
?>
CSS
<style type="text/css">
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 1.42857143;
color: #FF7878;
background-color: #000;
}
</style>
As can you see I'm trying to override the bootstrap css with my own. I don't have the time to use "Less".
In your .css file, you do not need to put <style type="text/css"> and </style>. These are only needed in the HTML file!
My file structure is as follows....
iamdan > css > style.css
My php file, head.php is in a file called includes which is in:
iamdan > includes > head.php
which contains the following code:
<head>
<title>Website title!!!</title>
<meta charset="UTF"-8">
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
Now it's loading the info fine and some of the style sheet (just the font style) none of the other styling is coming through...
Any ideas?
You have a mistake in your meta charset:
<meta charset="UTF-8">
And the other thing is:
<link rel="stylesheet" href="css/style.css" type="text/css">
This is relative from your script position. When you are in a subfolder. The path is wrong.
<link rel="stylesheet" href="/css/style.css" type="text/css">
Put a / before your path. Then your browser load the css file always from the root:
xx.de/css/style.css
Or put the complete URL before your script.
<link rel="stylesheet" href="http://xx.xx.de/css/style.css" type="text/css">