# Is there an HTML string type in Julia?

**URL:** <https://discourse.julialang.org/t/is-there-an-html-string-type-in-julia/7276>\
**Category:** General Usage\
**Created:** [November 23, 2017, 4:31pm UTC](https://discourse.julialang.org/t/is-there-an-html-string-type-in-julia/7276 "2017-11-23T16:31:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robblackwell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robblackwell/32/2720_2.png) [@robblackwell](https://discourse.julialang.org/u/robblackwell)\
**Post date:** [November 23, 2017, 4:31pm UTC](https://discourse.julialang.org/t/is-there-an-html-string-type-in-julia/7276/1 "2017-11-23T16:31:54Z")

</div>

When working in IJulia I find myself using this code:

```julia
struct HtmlString
    s::String
end

Base.show(io::IO, ::MIME"text/html", s::HtmlString) =
           print(io, s.s)
           
HtmlString("Result: <b>123.4</b")

```

I can then easily output tables of results as HTML etc. I can build up functions that return lumps of HTML for reports that appear inline in the notebook.

This feels fundamental - is there an HTML string type elsewhere that I’m missing please?

We have LatexStrings.jl, perhaps we should have HtmlStrings.jl?

Perhaps I’m missing a more idiomatic approach? Any wisdom appreciated please.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 23, 2017, 5:34pm UTC](https://discourse.julialang.org/t/is-there-an-html-string-type-in-julia/7276/2 "2017-11-23T17:34:55Z")

</div>

> [@robblackwell](#):
>
> This feels fundamental - is there an HTML string type elsewhere that I’m missing please?

`HTML("Result: <b>123.4</b")` in Base.

You can also call `display("text/html", "Result: <b>123.4</b")` if you just want to show something without constructing a new object.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/julialang/original/3X/1/2/12829a7ba92b924d4ce81099cbf99785bee9b405.png) [@system](https://discourse.julialang.org/u/system)\
**Post date:** [November 24, 2017, 5:35pm UTC](https://discourse.julialang.org/t/is-there-an-html-string-type-in-julia/7276/3 "2017-11-24T17:35:01Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
