Why is my stylesheet not linking to my XHTML?

38 Views Asked by At
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head> 
<title>Prac 3</title>

<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/> 

</head>

<body> 
<ul>
<li><a href="#Trade digital books in the midst of a pandemic.">Trade digital books in the midst of a pandemic.</a>.         </li>
<li><a href="#Worldwide ">Worldwide</a></li>
<li><a href="#South_Africa">South Africa</a></li>
<li><a href="#Conclusion">Conclusion</a></li>
<li><a href="#Sources">Sources</a></li>
</ul>
</body> 
</html> 

My style sheet is not linking to my XHTML but if it is a HTML it is working.

1

There are 1 best solutions below

2
Tim R On

I copied and pasted your example but had no issue. This is what I used 20 years ago for XHTML:

<?xml version="1.0" encoding="us-ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">


However, as was already commented, the community has moved on from XHTML. I believe this is the accepted standard these days:
Anatomy of an HTML document

<!doctype html>
<html lang="en">
<head>
  <title></title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

</body>
</html>

Bottom line to answer your question: You indicate trouble with XHTML, but you probably shouldn't be using XHTML. So don't use it and there's no issue linking your CSS.