# Hidden CSS?

**URL:** https://talk.observablehq.com/t/hidden-css/2343
**Category:** Help
**Created:** [September 4, 2019, 9:43am UTC](https://talk.observablehq.com/t/hidden-css/2343 "2019-09-04T09:43:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![rsakai](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/rsakai/32/2123_2.png) [@rsakai](https://talk.observablehq.com/u/rsakai)
#### Post date: [September 4, 2019, 9:43am UTC](https://talk.observablehq.com/t/hidden-css/2343/1 "2019-09-04T09:43:17Z")

</div>

I tried to replicate this forked notebook:

> **[Observable](https://observablehq.com/d/d4352dba699648ed)**
>
> The magic notebook for visualization.

as this:

> **[Observable](https://observablehq.com/d/b9c8b5a78cd675ef)**
>
> The magic notebook for visualization.

However, somehow the first notebook is loading the dc.css but I cannot figure out how it is importing the css because both notebooks imports the same libraries.

---

<div class="post-metadata">

### Author: ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)
#### Post date: [September 4, 2019, 2:26pm UTC](https://talk.observablehq.com/t/hidden-css/2343/2 "2019-09-04T14:26:57Z")

</div>

Welcome! Would you mind clicking “Enable link sharing” in the upper-right dropdown menu of each of these two notebooks so that we might see what’s going on?

---

<div class="post-metadata">

### Author: ![rsakai](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/rsakai/32/2123_2.png) [@rsakai](https://talk.observablehq.com/u/rsakai)
#### Post date: [September 4, 2019, 5:28pm UTC](https://talk.observablehq.com/t/hidden-css/2343/3 "2019-09-04T17:28:54Z")

</div>

Apologies! I have enabled link sharing on both!

---

<div class="post-metadata">

### Author: ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)
#### Post date: [September 4, 2019, 5:55pm UTC](https://talk.observablehq.com/t/hidden-css/2343/4 "2019-09-04T17:55:27Z")

</div>

The final cell of your first notebook (named `INJECTCSS`) is missing from the second one. When I copy that cell to the second notebook, the hover styles then work as expected. I guess the `INJECTCSS` cell is hard to see (unless you happen to hover over it) since it returns an empty `div`.

You may already know this, but a more Observable-idiomatic way to write `INJECTCSS` is with the `html` template tag function:

```auto
INJECTCSS = html`<link rel="stylesheet" type="text/css" href="https://unpkg.com/dc@3.0.4/dc.css">`

```

Using it this way also displays a more-visible `<link>` placeholder (though maybe you wanted to hide to it).

An alternative approach I’ve used before is to load resources together, so that e.g. the `dc` stylesheet and `dc` package are loaded in the same cell:

```auto
dc = {
  if (!document.getElementById('dc-stylesheet')) 
    document.head.appendChild(html`<link id="dc-stylesheet" rel="stylesheet" type="text/css" href="https://unpkg.com/dc@3.0.4/dc.css">`);
  return require("dc");
}

```

---

<div class="post-metadata">

### Author: ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)
#### Post date: [September 4, 2019, 7:10pm UTC](https://talk.observablehq.com/t/hidden-css/2343/5 "2019-09-04T19:10:37Z")

</div>

Another way to bundle JS and CSS without having to append to `<head>` would be to use `viewof`:

```javascript
viewof dc = {
  const PKG = 'dc@3.0.4';
  // <code>dc</code> just adds a visual clue to the cell's output.
  const view = html`<code>${PKG}</code><link rel="stylesheet" href="https://unpkg.com/${PKG}/dc.css">`;
  view.value = require(PKG);
  return view;
}

```
