skip to Main Content

I don’t have access to modify the source html and the classes cover such a large span of things, I’m having trouble adding to it as I want.

I’m trying to add text to the area that already has text.

Tried the following but it does nothing.

.content div:firstchild:after { content: 'Test'; }

When I do the following, it adds the text but it adds it numerous times because there are numerous divs and other elements (I’ve tried to add it directly into the table, after b, etc)

.content div:after { content: 'Test'; }

what I see when trying the above

the html of that section of the page from the console

2

Answers


  1. Your CSS selector has a typo in it, :firstchild should be :first-child.

    This should do what you need it to do:

    .content div:first-child:after { content: 'Test'; }
    
    Login or Signup to reply.
  2. With the :before and :after selectors you specify which content should be inserted before (or after) the content inside of that element. Input elements have no content.

            .content div:first-child:before
            {
                color: green;
                content: 'working ';
            }
            .content div:not(:first-child):after
            {
                color: green;
                content: ' is working';
            }
    
    
            .content div:before:first-child
            {
                color: red;
                content: 'this will never show up';
            }
            .content div:after:not(:first-child)
            {
                color: red;
                content: 'and this will not show up either';
            }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search