Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to separate Text and HTML with CSS

In order to improve the maintainability of a website, is it a good idea to separate all the text from the HTML and put it all in a unique CSS stylesheet? I mean, something like this:

HTML file

<body>
    <h1 class="home-title"></h1>
    <p class="description"></p>

    <!-- and much more elements... -->
</body>

CSS file with all the text

.home-title:after {
    content: "Welcome to my website!";
}

.description:after {
    content: "This is a demo ok?";
}

...
like image 796
albertoblaz Avatar asked May 23 '26 04:05

albertoblaz


1 Answers

No.

Style sheets are supposed to be used for the layout. The content should be in the HTML code.


Also, as jacktheripper pointed out, it would be a disaster for SEO purposes, as search engines will think that your page just contains a lot of empty elements.

like image 112
Guffa Avatar answered May 26 '26 21:05

Guffa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!