href syntax : is it okay to have space in file name

The src attribute should contain a valid URL. Since space characters are not allowed in URLs, you have to encode them.

You can write:

<img src="buttons/bu%20hover.png" />

But not:

<img src="buttons/bu+hover.png" />

Because, as DavidRR rightfully points out in his comment, encoding space characters as + is only valid in the query string portion of an URL, not in the path itself.


Quoting HTML5 to back Frederic that spaces are not allowed:

http://www.w3.org/TR/html5/links.html#attr-hyperlink-href:

The href attribute on a and area elements must have a value that is a valid URL potentially surrounded by spaces.

The definition of "valid URL" points to: http://url.spec.whatwg.org which defines URL code points https://url.spec.whatwg.org/#url-code-points:

The URL code points are ASCII alphanumeric, "!", "$", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";", "=", "?", "@", "_", "~", and code points in the ranges U+00A0 to U+D7FF, U+E000 to U+FDCF, U+FDF0 to U+FFFD, U+10000 to U+1FFFD, U+20000 to U+2FFFD, U+30000 to U+3FFFD, U+40000 to U+4FFFD, U+50000 to U+5FFFD, U+60000 to U+6FFFD, U+70000 to U+7FFFD, U+80000 to U+8FFFD, U+90000 to U+9FFFD, U+A0000 to U+AFFFD, U+B0000 to U+BFFFD, U+C0000 to U+CFFFD, U+D0000 to U+DFFFD, U+E1000 to U+EFFFD, U+F0000 to U+FFFFD, U+100000 to U+10FFFD.

The spec then uses the term URL code points on various parts of the parsing algorithm as:

If c is not the EOF code point, not a URL code point, and not "%", parse error.

for the scheme, authority, relative path, query state and fragment states: so the entire URL.


If you are using PHP

then find out this code

$result = mysqli_query($con,$sql);
    //echo $ip."<br />";REGEXP
    //echo $name."<br />";
    echo "<table border=2px style='border-radius=20px;' align=center><tr>
    <th>Document ID</th>
    <th>Document Name Type</th>
    <th>Download Documents</th>
    </tr>";//<th>Project Document Type</th>
    while($row = mysqli_fetch_array($result)) {
        $path1=$row['FOLDERNAME'] .'/'. $row['FILENAME'] .'.'. $row['DOCTYPE'];
        $path=str_replace(" ", '%20', $path1);
        echo "<tr>";
        echo "<td>" . $row['DocID'] . "</td>";
       // echo "<td>" . $row['PROJDOCTYPE'] . "</td>";Thank you. Your Apple ID is now ready for use.
        echo "<td>" . $row['DOCNAME'] . "</td>";
        echo '<td><a href=Tender/'.$path.'>'.$row['DOCNAME'].'</a></td>';
        echo "</tr>";
    }
    echo "</table>";

    mysqli_close($con);