I should note that the website I'm working on is meant to be pretty simple.
The way I have my website files organized is that under one folder containing the entire website, I have the .html file for the home page, which contains links to different pages inside it for photos, videos, etc. Each of these pages have their own folders.
Attached here is the code I have for one of these pages, meant for my photos. I learned from this thread (Link not going back to home page) that if you just have:
Home
That the link will take you back to the index/root directory.
(Is this different from the home page? Sorry, I'm a noob.)
Although, when I originally had it has just the code above, the link takes me to this weird gray page that just shows all of the files of my website (is that root place or whatever it's called?).
Although, I see that I'm able to from there just simply add the .html file for my home page in that link directory, so the code I have now seems to work.
Is this an okay way to have a link to go back to the home page? Thank you for your time.
<!DOCTYPE html>
<html>
<style>
div.img {
display: inline;
max-width: 650px;
}
</style>
<body>
<div> <!--Home Button-->
<a href="/homepage.html" style="float: right; margin-right: 100px;">
Home
</a>
</div>
<div class="img">
<img src="1.jpg" width="384px;" height="384px;">
<img src="2.png" width="384px;" height="384px;">
<img src="3.png" width="384px;" height="384px;">
<img src="4.JPG" width="384px;" height="384px;">
<img src="5.png" width="384px;" height="384px;">
</div>
</body>
</html>
If it works and you are okay with having the path /homepage.html as your home page, then it is a perfectly good and logical way of linking back to the home page.
As Kei mentioned in the comment, it is highly advisable to rename this file to index.html as most web servers and browsers will default to this file name as the root. For a lot of people, it's more desirable to just go to a domain (ie: mydomain.com) as the home page, rather than having to type in mydomain.com/homepage.html.
All this to say, if you rename your home page file to index.html and serve this website through a web server of some sort (Apache for example), then you can simply use / as a path and it will bring you directly to the home page. I know that you mentioned that you are a beginner, so this may be slightly outside of the scope of what you are asking, but just letting you know for the future. Good luck!
Related
I am updating my online portfolio with a new website (I grabbed a template off Free-Css.com). When I preview it, it works fine. Once I deploy the website via Firebase, none of my images appear.
All of the images are in the public folder, which is where my hosting is set to. Here is an example of one of the images:
<div class="col-md-6 about-img-div">
<!-- <div class="about-border" data-aos="fade-up" data-aos-delay=".5"></div> -->
<img src="Headshot.jpg" width="400" class="img-responsive" alt="" align="right" data-aos="fade-right" data-aos-delay="0" />
Even if I use the pull pathname, the images still do not appear. Please note that they do appear if I just open the HTML file, but not while deployed. What am I doing wrong? Here is the website: https://evanmny.com
I'm not sure how you create/generate the HTML, but when I look at the network tab when loading your site in a browser I see it tries to read this URL:
https://evanmny.com/Users/evanmullen/Public/city.jpg
That should be:
https://evanmny.com/city.jpg
I have a simple html page :
#my_svg{
width: 75px;
height: auto
}
<a href="#">
<div id="my_svg">
<img src="https://svgshare.com/i/MHB.svg" alt="English flag">
</div>
</a>
All I see is English flag so it seems like my svg is not loading. I'm sure about the path because I have the image as png on the same folder and it's working well. Just changing the extension.
The weird part is that I don't have any 404 error in my console. It's working when I add it throught the link https://svgshare.com/i/MHB.svg but when I use the local file it doesn't work. On my side I don't have any webserver and don't want
So your problem is its not working on the local file right? I think it will work if you use <img src="./flag.svg" alt="English Flag'>. That should work, sometimes not adding "./" on the src attribute will have issues because the browser might think it is a web link, not a path link.
I am a student who is making an app for my group's STEAM Tank project. I can't figure out how to make a button link go to another HTML file in chrome-dev tools. I am working in an index.html file to make the title page. This is the code I have:
<img src="2icon_128.png" alt="Tardy Time logo" width="400" id="tardy-time-logo">
<h1 id="tardy-time-heading">Tardy Time</h1>
<h2 class="tardy-time-slogan"><strong><em>If you can't beat Tardy Time, Join Tardy Time</em></strong></h2>
<div class="header">
<span class="title-btn"><a target="_blank" href="file:///home/chronos/u-e6b8f2a6cde1e9636abef34ef65d593e08bdd9e8/MyFiles/Downloads/Tardy-Time-App/beginning.html" class="title-btn">Let's Start</a></span>
</div>
I need to get to a file called beginning.html, which is located inside the same folder, "Tardy-Time-App". The error I am getting is the not allowed to load local resource error. I am working in chrome devtools.
Is you're in the same folder just pass the name of your file like this:
<a target="_blank" href="beginning.html" class="title-btn">Let's Start</a>
So you don't need to pass the absolute path of your file
The code snippet in html format is showing as below.
there are three requirements listed below for reference as well.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Images and Links - Fast Broccoli!</title>
</head>
<body>
<div class="content">
<h1>Fast Broccoli! - About Us</h1>
<!--
Use images and links to build an "About Us" page for Fast Broccoli!,
the world's first one-hour organic produce delivery service.
You'll need:
1. A main image with source: https://upload.wikimedia.org/wikipedia/commons/0/03/Broccoli_and_cross_section_edit.jpg
and alt description: Fast Broccoli!'s Logo
2. A link to the relative path: index.html
with the text: Return Home
3. A second link to the absolute path: https://shop.fastbrocolli.com
The link should target a new browser window.
The link should contain an image
with source: images/cabbage.png
-->
</div>
</body>
</html>
This strangely looks like a school project. I could just give you the solution to your assignment, but I believe it would be better if you learn it.
Hope you enjoy!
Image Tag
Here's an example img tag from W3Schools:
<img src="smiley.gif" alt="Smiley face">
This is pretty simple. The source is smiley.gif and the alt description is Smiley face. Now do you know how to make your own image tag? Otherwise, click the link above for more details.
Links
Relative
A relative link is, well, relative. Where it goes depends on where the current URL.
A relative link is anything that does not begin http://, https://, file:///`, etc.
In the most basic sense, it's the current URL + the relative path. (Less simple, it's telling the browser it's in the same folder as the current page).
Example: If I added a link on this page that looks like:
Click me
It would go to:
https://stackoverflow.com/questions/47361572/relative-and-absolute-html-path/hi.html
Because:
https://stackoverflow.com/questions/47361572/relative-and-absolute-html-path + hi.html
If it begins with a forward slash (/), it will take the domain of the site and add to it. (Less simple, it's telling the browser the file is in the root directory of the site).
Example: If I added a link on this page that looks like:
Click me
It would go to:
https://stackoverflow.com/hi.html
Because:
https://stackoverflow.com + hi.html
Absolute
An absolute path is absolute. It doesn't add to the end, but is an entirely new domain.
Example: If I added a link on this page that looks like:
Click me
It would go to:
http://example.com/
Because it begins with http://
Notes
In all the examples, the text of the links was "Click me".
More info on file paths.
More info on the target attribute. (Allows you to "target a new browser window.")
i m getting this error "I can't find your main image with src="https://upload.wikimedia.org/wikipedia/commons/0/03/Broccoli_and_cross_section_edit.jpg". Please add it."
<h1>Fast Broccoli! - About Us</h1>
<img src="Broccoli_and_cross_section_edit.jpg" alt="Fast Broccoli!'s Logo"
style="width: 60px;"/>
Return Home
<a href="https://shop.fastbrocolli.com">
<img src="images/cabbage.png" />
</a>
this is pretty basic but I can't figure out why my image won't render. The broken image icon doesn't appear and I'm viewing my page on localhost. I'm not sure how to upload a screen shot but I've played with the relative path in many ways and can't figure out the problem. When I link to an online image it renders. I'm using rails/foundation currently but I actually had the same problem using a MEAN stack a couple weeks ago. The issue seems to be only when using a server. Any help is appreciated, thanks. EDIT: my views and assets folder are at the same level (siblings?) views path: app/views/projects/home.html.erb. images path: app/assets/images/volvo.jpg; I've selected the image file and done 'copy relative path' and played with it every which way. I don't think it's the path but who knows.
<h4>pic below</h4>
<img src"../../assets/images/bmw.jpg"/>
<h4>pic above</h4>
<h2>photo gallery</h2>
<ul>
<li>
<img src"assets/images/bmw.jpg"/>
<img src"../../assets/images/volvo.jpg"/>
<img src"saab.jpg"/>
<img src"../../assets/images/saabtwo.jpg"/>
</li>
</ul>
You are defining your images incorrectly; you forgot the equals sign (=). You need to have src= instead of just src before the image path. This is because of the way the defining/setting of attributes works in html.
For your code, this would be:
<h4>pic below</h4>
<img src="../../assets/images/bmw.jpg"/>
<h4>pic above</h4>
<h2>photo gallery</h2>
<ul>
<li>
<img src="assets/images/bmw.jpg"/>
<img src="../../assets/images/volvo.jpg"/>
<img src="saab.jpg"/>
<img src="../../assets/images/saabtwo.jpg"/>
</li>
</ul>
As a general rule, to define a style in html, you do this: attribute="value".