September 10, 2024

Hightlight text using Markdown, CSS and HTML

To highlight text, use the tag in your markdown.md file, like that:

<mark>text you want to hightlight</mark>

The expected outcome is this:

text you want to hightlight

then, to customize the hightlight, add the following snippet of code to your CSS file (for example style.css):

/* This styles the tag <mark> */
mark {
    background-color: antiquewhite;
    color: blue;
    padding: 0 0.04em; # you can adjust lenght and height of the padding with this
}

If you did not have a CSS file and created one for this, make sure that you add the following snippet of code:

<link href="style.css" rel="stylesheet" />

in the header of index.html, like this:

<!DOCTYPE html>
    <head>
        <link href="style.css" rel="stylesheet" />
    </head>
    <body>
    </body>
</html>

so the CSS file, style.css is sourced.


personal computing web development wiki css markdown html

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88