Hello I am trying to move back 2 directories.
For example i have a file in my root folder ie: /root/FILE that links this stylesheet successfully with the file location being /root/blog/wp-content/themes/dazzling/inc/css/CSS-FILE.css"
<link href="blog/wp-content/themes/dazzling/inc/css/font-awesome.min.css" rel="stylesheet" type="text/css">
Now I want to link in the same stylesheet in a file located in a folder that is /root/eliquid/includes/FILE and in there and I am attempting to use
<link href="../../blog/wp-content/themes/dazzling/inc/css/font-awesome.min.css" rel="stylesheet" type="text/css">
I also attempted
<link href="../..blog/wp-content/themes/dazzling/inc/css/font-awesome.min.css" rel="stylesheet" type="text/css">
But not sure what im doing wrong! Any help is much appreciated!
Have you tried using an absolute link rather than a relative link? If your CSS file is at http://www.example.com/blog/wp-content/themes/dazzling/inc/css/font-awesome.min.css then you can include it on any page of your website as
<link href="/blog/wp-content/themes/dazzling/inc/css/font-awesome.min.css">
Related
enter image description hereI added a css link to my php file, but it won't show the changes.
My css file is named register.css and my php file is named register.php.
<?php
include("includes/config.php");
include("includes/classes/Account.php");
include("includes/classes/Constants.php");
$account = new Account($con);
include("includes/handlers/register-handler.php");
include("includes/handlers/login-handler.php");
function getInputValue($name) {
if(isset($_POST[$name])) {
echo $_POST[$name];
}
}
?>
<html>
<head>
<title>Welcome to Napster!</title>
<link rel="stylesheet" type="text/css" href="assets/css/register.css"/>
</head>'
My css file is in assets file which is in same file as my php file.
I am using xamp and sublime text.
it seems the issue is either browser cache or related to path..
please try
<link rel="stylesheet" type="text/css" href="assets/css/register.css?v=1.1"/>
if register.php is not in root folder then try..
<link rel="stylesheet" type="text/css" href="../assets/css/register.css?v=1.1"/>
here ?v=1.1 is added to load updated css. whenever you make changes in css file, simply chage v=1.1 with another number like v=1.2 etc... to avoid clear cache in browser and load updated css...
I work on my website but I have a problem with the links in the href.
My CSS and javascript files are in this folder (in the root of my site):
assets/stylesheets/file_css.css
For now the links of my href looks like this:
<link rel="stylesheet" href="./assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="./assets/fonts/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="./assets/stylesheets/custom.css">
<link rel="stylesheet" href="./assets/stylesheets/media-queries.css">
I call it in all my php files with :
require_once __DIR__.'/layouts/header.php'
Problem:
When I want to create a folder to sort my files eg views (folder found at the root of my site)
Looks like views/test.php
All href don't work, console error :
test.php:10 GET http://localhost/mywebsite/views/assets/bootstrap/css/bootstrap.min.css
test.php:11 GET http://localhost/mywebsite/views/assets/fonts/font-awesome/css/font-awesome.min.css
test.php:12 GET http://localhost/mywebsite/views/assets/stylesheets/custom.css
In fact, my CSS aren't in views folder.
I tried many things
1 - <link rel="stylesheet" href="/assets/bootstrap/css/bootstrap.min.css">
error => test.php:10 GET http://localhost/assets/bootstrap/css/bootstrap.min.css
2 - <link rel="stylesheet" href="<?php echo __DIR__ ?>/assets/bootstrap/css/bootstrap.min.css">
error => test.php:10 Not allowed to load local resource: file:///C:/wamp/www/mywebsite/layouts/assets/bootstrap/css/bootstrap.min.css
I thought to put href="/mywebsite/assets/bootstrap/css/bootstrap.min.css" in the first link, it works locally but not on the server
I really need help, I start having too much PHP file at the root
Thank you
my CSS file "styles.css" isn't loading. I'm on a mac and my PHP server is set to be loading from my "PHP" folder on my desktop.
Here is the file path to the css folder: /Users/evanbutler/Desktop/PHP/css
Code from the PHP doc:
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/Users/evanbutler/Desktop/PHP/css/styles.css">
<title>Create a Business Card</title>
Proper way is copy style.css from your desktop to project folder/css. then include css by href="css/styles.css"
They are four method to link css file into html:
Linking to a separate CSS file
<link rel="stylesheet" type="text/css" href="mystyles.css" />
Embedding CSS into the HTML
<style media="screen" type="text/css">
Add style rules here
</style>
Adding Inline CSS to HTML tags
<h2 style="color:red;background:black;">This is a red heading with a black background</h2>
Importing a CSS file from within CSS
#import "newstyles.css";
You should use a relative path to your css file from your root folder of your working project. Are you using an environment like XAMPP to test your local project on? If so, your css relative url would be a href="css/styles.css"
I am currently working on a admin backend and now want to move some pages into different folders (so I do not have all scripts in one folder).
Structure looks like this:
/
/theme/assets/...
/templates/head.php
/templates/foot.php
/top/index.php
/index.php
In head.php there are some stylesheets added like this
<link href="theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
This works fine for files in the root folder (e.g. index.php), but when I use the same head.php in /top/index.php it does not work because the path is wrong.
Is it somehow possible to properly include the stylesheets etc. while having the scripts in different folders?
Greetz,
Just specify the root identifier (/) at the beginning of the href attribute:
<link href="/theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
Try this,
<link href="../theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
In /top/index.php
OR
<link href="<?php echo $_SERVER['DOCUMENT_ROOT'] ?>/theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
This code can be used in any page. The $_SERVER['DOCUMENT_ROOT'] points to the root.
Use '../' to reference the folder above and work your way back.
e.g
<link href="../theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
I have following code for my header.php file, in the includes folder.
<html>
<head>
<title>Health Mate</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link href="stylesheets/public.css" media="all" rel="stylesheet"/>
</head>
<!-- Some more code-->
</html>
I have pasted favicon.ico in the includes folder itself.Problem is the favicon is not setting up.Also If i redirect user to some site on submit button like yahoo.com . My site is taking favicon of yahoo. Please suggest some solution. Also tell me if favicon needs to be .ico file or it can be .png as well?
You should have necessary path needed to locate your favicon.ico image.
Eg: If your folder is structured this way:
/mysite
/includes
favicon.ico
index.php
If you're going to use it in index.php you should include the necessary path needed like this:
<link rel="icon" href="includes/favicon.ico" type="image/x-icon" />
Note: for checking if your like get the path towards your icon image..
you could check your web page source code using ctrl + u. Then click the href path linked if it displays the image it means your path is correct.
You have to put favicon.ico in to root directory of your website such that anyone can access it by yourdomain.com/favicon.ico. yourdomain.com/includes/favicon.ico will not work without a link tag.
If you can't put the favicon on the root folder for your domain then you have to use this code and change the href attribute to match the path to the favicon relative to the root of your site. i.e. /includes/favicon.ico
<link rel="Shortcut Icon" type="image/ico" href="/includes/favicon.ico">
I would recommend converting the file to an actual .ico using http://www.icoconverter.com/ or some equivalent tool.