Reputation: 1
I've looked, this has never been answered.
I have many HTML pages that used a template, the template is stuck and since I'm using only HTML, CSS & slightly JavaScript I need a solution that changes where people look for the title.
I want CSS to have a title, I only have 1 CSS page and about 15 / 20 HTML pages with the tag undefined. Is there a way to have CSS contain the title?
Thank you if you can,
Upvotes: 0
Views: 99
Reputation: 855
If you want to add text to a particular element with CSS you can use the pseudo-selector "before":
#title:before {
content: "Your title";
}
Upvotes: 0
Reputation: 10189
CSS is a language used only for styling webpages. It is not used to store data so you will not be able to store the title in the CSS.
One bad approach could be that just write the title on the CSS file on the first line then use Javascript and then read the file's first line and set that as the title using Javascript.
One good approach could be that set the title using javascript. Make a simple javascript file and add document.title='your_title';
in that and include that in every HTML page. That will create a title for your webpage but ofcourse that will be equal to adding a <title>
tag on every HTML page, the difference would be only of not writing <title>
but writing some script.
Or one another approach could be that make some C# or any other language in which you are at your best program that will insert a title attribute in your HTML file :P
Upvotes: 1
Reputation: 44746
Assuming that you mean the title
element within head
, one option, if you can, would be to use JavaScript.
// set current title to foo
document.title = 'foo';
Upvotes: 0