Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css { content: "text"}, how do I add tags?

Tags:

css

People also ask

How do I add tags to CSS?

CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.

Can I put HTML in content CSS?

Unfortunately, this is not possible. Per the spec: Generated content does not alter the document tree.

What is content tag in CSS?

CSS has a property called content. It can only be used with the pseudo-elements ::after and ::before. It is written like a pseudo selector (with the colon), but it's called a pseudo-element because it's not actually selecting anything that exists on the page but adding something new to the page.


The content declaration cannot add tags to the page (tags are structural); additionally, CSS is meant for presentation changes, not structural content changes.

Consider using jQuery, instead, such as:

$(".HeaderName").after("your html here");

If you need that extra tag only to make the added text red, just do this:

.HeaderName:after{
    content: "text";
    color:red;
}

Tested on Chrome.


You can't insert tags using content: in CSS. Here is the relevant part of the spec; see the 'content' property in the CSS 2.1 spec.