chiark / gitweb /
Convert the fading <div> in the Web page back to a <span>
authorBen Harris <bjh21@bjh21.me.uk>
Fri, 27 Sep 2024 18:07:50 +0000 (19:07 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Fri, 27 Sep 2024 18:07:50 +0000 (19:07 +0100)
HTML doesn't allow <div> inside <h1>.  I found before that using a
<span> caused the background not to work.  That seems to be down to CSS2
section 10.6.1, describing inline, non-replaced elements: "The height of
the content area should be based on the font, but this specification
does not specify how."

Happily, we can just define this particular <span> to be a block
element, so that it behaves like a <div> even though it's a <span>.
That works fine, and because we're only using it to get a well-defined
content area it doesn't matter if it's ineffective when the stylesheet
is missing.

bedstead.css
index.xhtml

index 9eb4a24affb788213ffa922ada70b2ac9313af36..c79403993aec6b0b9a7215dd34b90cf7fe6d13e9 100644 (file)
@@ -38,6 +38,7 @@ h1 {
 }
 
 .fade {
+    display: block;
     -webkit-mask-image: linear-gradient(to right, transparent 1em, white 3em);
     mask-image: linear-gradient(to right, transparent 1em, white 3em);
 }
index bc81c347011eeaa421534c01945ee29a3f490d55..4a2c5047b71b40822dc405d27895d85e24a5bc92 100644 (file)
@@ -12,7 +12,7 @@
     <link rel="icon" href="icon-64.png" type="image/png" sizes="64x64" />
   </head>
   <body>
-    <h1><div class="fade">Bedstead</div></h1>
+    <h1><span class="fade">Bedstead</span></h1>
     <p>Bedstead is a family of outline fonts based on the characters
       produced by the
       Mullard SAA5050 series of Teletext Character Generators.  The