DEV Community

Cover image for How to Hide Text in a Logo Using CSS
SnippFlow
SnippFlow

Posted on

How to Hide Text in a Logo Using CSS

To hide the text of a logo and show a background image, you can use this CSS technique. This method uses text-indent to move the text out of the visible area and other properties to keep it hidden without affecting the layout.

a.logo {
    text-indent: -9999px;  /* Shifts the text far off-screen */
    overflow: hidden;      /* Ensures no overflow text is visible */
    white-space: nowrap;   /* Prevents text from wrapping to the next line */
    display: block;        /* Allows setting width and height */
    width: 150px;          /* Sets the width of the logo element */
    height: 50px;          /* Sets the height of the logo element */
    background-image: url('logo.png');  /* URL of the logo image */
    background-size: cover; /* Ensures the background image covers the entire area */
}
Enter fullscreen mode Exit fullscreen mode

Full article: How to Hide Text in a Logo Using CSS
CSS Snippets

Top comments (0)