I'm having trouble linking an image from a different folder - html

<head>
<title> URL Practice </Title>
</head>
<body>
<img src = "./bloo/chicken.png">
</body>
I'm trying to learn how to do relative URL links and I've been trying to get it to link to an image from a folder that's inside the original file. It's not working and I don't understand why, I feel like I've tried every variation.
This is what I'm working with if that helps
Also I'm really new to this, so if you can explain it to me like you would a 3 year old, that would be awesome because that's probably where my level of expertise is.

I understand that the image is in the "bloo" folder. Your HTML file and the bloo folder are both children to the root folder. For you to link to link the image, you need to need to reference it like this
src="bloo/imagename.jpg"
it will reference it correctly that way.
So your code snipest will look like
<img src="bloo/chicken.jpg"/>
Good luck

No space shall be between "src", "=" and "bloo/chicken.png". Also u don't need that dot. you can install "VisualStudioCode" will be easier.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="MyImages/meme.jpg" alt="meme">
</body>
</html>
meme.jpg is inside MyImages folder

enter code here
HTML Input src Attribute
\

Related

Why css file is loading a blank page?

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content= "ie= edge">
<title>Blooger</title>
<link rel="stylesheet" type="text/css" href="./css/style.css" />
</head>
I have searched a lot, checked my syntax of linking css n times and spelling of style sheet is correct, the folder I am using is correct I don't know the problem, please help.
I'm not sure whether you've not added it here on SO, but your HTML file doesn't contain anything to show. (no <body></body> or anything within it)
As an example, you need to add
<body>
<h1>My Blog</h1>
<p>welcome to my blog.</p>
</body>
Please check status, type and size in network tab of browser developer tool

Why won't my image load in html even tho I put the image in the same folder?

I'm trying to learn html and I'm trying to add an image, I put the image in the same folder as my html file and named it spoder.png. When I tried to load it up in my browser, the image won't appear and only the alt message comes up. How do I fix this?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<img src="/spoder.png" alt="image cannot load">
</body>
</html>
If it's in the same folder, the src atrribute must be src="spoder.png" (no slash)
Agree with the previous answer and will just add that the leading slash always points back to the root.

My CSS file won't link and I don't know why

I'm trying to link p1.css to p1.html, but for some reason it's not working. It's in a file on my desktop called 115, and in a file inside called css, but no matter what I add or take away it won't show up. What am I doing wrong?
<!DOCTYPE html>
<html lang="en">
<head>
<title>CIS 115 - Project 1</title>
<p lang="en"></p>
<meta charset="utf-8">
<meta name="Project 1" content="">
<meta name="Kim Peoples" content="Kim Peoples">
<link rel="stylesheet" type="text/css" href="115/css/p1.css">
<script src="115/p1/p1.js"> </script>
</head>
this is the css, which is I'm in the process of making but I want to make sure it links first.
body {
background-color: green;
}
Im assuming that you are viewing/accessing your file via desktop. Though not clearly sure if you are using localhost server or not. Here's what I think what was your file tree flow..
/115
-/css
-- p1.css
-/p1
-- p1.js
- index.html
Then in your HTML, it should look like this.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CIS 115 - Project 1</title>
<meta name="description" content="Kim Peoples - CIS 115 Project">
<link rel="stylesheet" type="text/css" href="css/p1.css">
<script src="p1/p1.js"> </script>
</head>
Note: Since you are initiating the index inside your 115 folder, you don't have to include 115 folder to your internal files. Just simple append the folders of your media files and CSS/JS files.
first you have to press ctrl + u on browser window and check css path
has been coming or not? after click it css will be display properly
or not ?
if still issue then check with inspect element in browser. press f12
in browser window.
still issue then you can use element property in !important; in css
code
Maybe try ../115/css/p1.css?
Seems like your absolute path is incorrect.
Here is a link to more information about absolute paths and relative paths:
Absolute vs Relative Pathlinks
Hopefully this is helpful to you.
Happy Coding!

how do i add an image in the background in css from a folder?

I have an image, and from what I've seen in W3schools you can just use
body background = farm.jpg
And that works, but it says and I've seen people say this, that it can work with css with
background-image: url(farm.jpg) (with and without quotes)
yet whenever i try it can't find the picture.Do I need to put it in a separate folder?
It depenteds to where is your css file , put your css file and image file into same place, and try below
background-image: url("frame.jpg");
Or you can use / to start from root folder.
background-image: url("/frame.jpg");
Read this.
(1) https://www.w3schools.com/tags/att_body_background.asp
Unfourtunately the background attribute is not supported in HTML5. You must use CSS instead.
(2) You can use the code example form this page, what works:
https://wiki.selfhtml.org/wiki/CSS/Eigenschaften/Hintergrundfarben_und_-bilder/background-image
For example:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Your page</title>
<meta name="description" content="The HTML5 page">
<meta name="author" content="Your Name">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<style>
body {
background-image: url("background.png");
}
</style>
</head>
<body>
<p>Test.</p>
</body>
</html>
Hope this helps.

html not linking css

I'm having an issue with linking html and Css and have no idea why. I'm doing everything like the book and tutorials says. However, I'm not getting to do the external configuration of css.
This is the code(just a test):
<!DOCTYPE html>
<html lang = "eng">
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>title</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheets" type="text/css" href="/styles.css">
</head>
<body>
<h1>test</h1>
</body>
</html>
and CSS:
body {
background-color:#CCCCCC;
}
h1 {
color:#0000EE;
}
Maybe I miss something, because when I do internal css (within my html code with ) it goes ok and the web browser is able to read that. It seems like the html is not linked with css, but it's even on the same folder so the path shouldn't be the problem.
I'm using Linux and Aptana Studio.
I've searched a lot the last 2 hours and cannot find where the mistake is.
I invite you to read this article Absolute and Relative Paths
Then we pass to your code:
<link rel="stylesheets" type="text/css" href="/styles.css">
Should be :
<link rel="stylesheet" type="text/css" href="styles.css">
Your styles.css should be in the same folder as your html file.
To verify that you have an error , check Console of your browser,you will be noticed that your file doesn't exist(404 error).
An other way to make your css working is to integrate it inside your page without separation:
Example:
<style type='text/css'>
body {
background-color:#CCCCCC;
}
h1 {
color:#0000EE;
}
</style>
If the other suggestions don't work, you can try re-saving the HTML and CSS sheets with "UTF-8" encoding and declare UTF-8 encoding in the HTML under the <head> with <meta charset="utf-8>"
The rel attribute should just have stylesheet in it, singular not plural as well
I had the same problem correct the correct directory structure solved my problem. This is a good visualiton on how to organize your directory structure.
http://rosebusch.net/jeff/miscellaneous/tree.html
That is, the index.html folder is on the same level as the CSS folder. If you want to put index.html in a HTML folder, to link to the CSS folder you would have to backout first by linking href="../css/stylesheet.css". The ".." will take you up a level.
Make sure style.css is in your root web directory since that is where you are calling it from
Don't put the / in front of styles.css and make sure they are in the same folder.
Try this instead:
<!DOCTYPE html>
<!-- Language was wrong? -->
<html lang = "en">
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>title</title>
<meta name="description" content="">
<meta name="keywords" content="">
<!-- Check the path to the file - I made it relative to where the HTML is -->
<!-- Correct the rel attribute's value too -->
<link rel="stylesheet" type="text/css" href="./styles.css">
</head>
<body>
<h1>test</h1>
</body>
</html>
If all the above not working:
1- Make sure you have no inline/internal CSS > Delete all style code from the Html page (it ll prevent external css link)
If your CSS file are in another folder then use
<link rel="stylesheet" type="text/css" href="folder-name/styles.css">
I found out while Using Visual Studio Code and adding quotes that it was quoting automatically. So when I put in quotes and looked in the index.html of the index it was quoting the quotes (Bad News). Try link
<href=FILENAME.css rel=stylesheet type=text/css />
Hope this works! Also, if you want Multiple CSS files, organize them in a folder, if you do so in FILENAME put /FOLDERNAME/FILENAME.css
BUT make SURE it is under the main folder where your Index is!
just try tasking off the / in front of the style.css
Place your link in the head tag or body tag, it is best to put it in the head tag.