我正在学习 html,但我对 href 的工作原理感到困惑
好的,我现在正在学习 html,很快就会学习 css。在我的 html 编码中,我有一个像这样的导航部分:
<div id="header">
<h1>Guild Wars 2 Fanbase</h1>
<ol id="navigation">
<li><a href="/">Home</a></li>
<li><a href="/facts">Facts</a></li>
<li><a href="/gallery">Gallery</a></li>
<li><a href="/code">Coding</a>
<ul><li><a href="/code/line">Lines</a></li>
<li><a href="/code/comment">Comment Lines</a></li>
</ul>
</li>
</ol></div>
现在,当我打开这个 .html 文件时,这一切都按照我想要的方式布局(即标记)。我的问题是,当我单击此网站上的链接(此网站是此代码)时,我收到一条错误消息,指出找不到此网页,但是当然。但是我该如何创建它才能让网页一起工作呢?我不知道如何正确表达。就像,我是否在同一目录中创建另一个 .html 文件,以便当我单击链接时它会从第二个 .html 文件中读取?
如果您不确定我在问什么,请告诉我,我会尽力说得更具体。谢谢你的帮助(:
请原谅我的语法错误,不是世界上最好的英语,尽我所能(:
Okay so i'm learning html right now and soon css. In my html coding I have a section like this for navigation:
<div id="header">
<h1>Guild Wars 2 Fanbase</h1>
<ol id="navigation">
<li><a href="/">Home</a></li>
<li><a href="/facts">Facts</a></li>
<li><a href="/gallery">Gallery</a></li>
<li><a href="/code">Coding</a>
<ul><li><a href="/code/line">Lines</a></li>
<li><a href="/code/comment">Comment Lines</a></li>
</ul>
</li>
</ol></div>
Now when I open up this .html file this is all layed out the way I want it too look (the mark up that is). My question is this, when I click on a link on this site (this site being this code) I get an a error saying this webpage is not found, but of course. But how do I create it so I can have the web pages working together? I'm not sure how to word it correctly. Like, do I create another .html file in the same directory so somehow when I click the link it reads from the second .html file?
If you not sure what I'm asking, just let me know and I'll try to be more specific. Thank you for your help (:
excuse my mistakes in grammar, not the worlds best in English, trying my best (:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 @Craig T 所提到的,您的 href 应该指向另一个页面。
这些与您现有的网站相关,其中“/”是最顶层的页面。
'/facts' 实际上是指相对于 '/' 的名为facts 的目录
,但是,它们不必指向另一个 html 页面。
他们还可以指向另一个网站。
例如
,或者其他站点的特定页面:
在 html 代码中,您提供了指向目录的 URL 点。当未提供特定文件或资源时,即它不以 /page/yourpage.html 结尾,则由网络服务器决定如何处理它。他们通常会有规则来确定这一点。
例如,apache web 服务器通常配置为返回请求目录中的文件index.html。
所以这些:
等价于这些:
在某些设置中,默认值不是index.html,而是index.php 或index.asp。
实际上大多数都是按优先顺序进行的。
例如,首先尝试index.php,如果不可用,请尝试index.html
我希望这是清楚的。
As mentioned by @Craig T your href's should point to another page.
These are relative to your existing website where '/' is the topmost page.
'/facts' is actually refering to a directory called facts relative to '/'
However, they need not point to just another html page.
They can also point to another website.
e.g.
Or a specific page at other site:
In the html code you provided the URL's point to directories. When a specific file or resource is not provided i.e. it doesn't end in something like /page/yourpage.html then it's up to the webserver to decide how to handle it. They will usually have rules to determine this.
e.g. the apache webserver is often configured to return the file index.html in the requested directory.
So these:
Are equivalent to these:
On some setups instead of the default being index.html it's index.php or index.asp.
Actually most go by an order of priority.
e.g. try index.php first and if not available try index.html
I hope that's clear.
在这个问题的上下文中,您的 href 应该指向另一个 html 页面。
例如:
您需要在站点的根目录中创建一个facts.html 页面。
In the context of this question your href's should point to another html page.
For example:
You would need to create a facts.html page in the root directory of your site.
这是有人曾经给过我的一个关于 URL 的很棒的链接: http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/
-- 哎呀本来是一条评论,抱歉:P
Here's an awesome link someone gave me once, about URLs: http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/
-- oops was meant to be a comment, sorry :P