Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
119 views
in Technique[技术] by (71.8m points)

html - Relative pathnames working differently on Safari and Chrome

I'm finding that relative path names in HTML are working differently in Safari (14.0.3) and Chrome (88.0.4324.96) on my MacBook.

If I have all the files in one place (see below), everything is fine, both in Safari and Chrome.

<!DOCTYPE html>
<html>

<head>

    <!-- the style sheet is local -->
    <link rel="stylesheet" type="text/css" href="style_sheet.css" />

    <title>HTML 101 - title A</title>

</head>

<body>
    <p>This is a line of HTML - page A</p>
    <! -- let's have a local picture -->
    <img src="yellow.jpg" alt="Welcome!">
</body>

</html>

But I want the HTML and pictures to be in different places. Suppose I have an 'html' directory and an 'images' directory, with a style sheet one level above. (See below.) This works fine in Chrome, but in Safari, the style sheet is not picked up, and the image is not displayed.

<!DOCTYPE html>
<html>

<!-- let's start at the very beginning -->
<head>

    <!-- the style sheet is one level above -->
    <link rel="stylesheet" type="text/css" href="../style_sheet.css" />

    <title>HTML 101 - title B</title>

</head>

<body>
    <p>This is a line of HTML - page B</p>
    <!-- the image file is in a sibling folder -->
    <img src="../images/yellow.jpg" alt="Welcome!">
</body>

</html>

How do relative pathnames work in HTML in Safari?

question from:https://stackoverflow.com/questions/66067544/relative-pathnames-working-differently-on-safari-and-chrome

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...