2

Can you define an iframe's src attribute in css as opposed to in the html tag? Is there a fundamental reason why this wouldn't work?

I wanted to clean up my HTML a little bit by moving a long source link out of the main page but couldn't find an answer to this anywhere.

4
  • 4
    No, you can't. CSS is supposed to define style, not contents. Commented Feb 24, 2015 at 15:22
  • @AlexShesterov You can define text content wih css. Commented Feb 24, 2015 at 15:22
  • 1
    @Hacketo, but you should use it for styling only, e.g. adding a colon after dt elements. Definitely not for adding significant content. Commented Feb 24, 2015 at 15:23
  • "I wanted to clean up my HTML a little bit by moving a long source link out of the main page" Doing so by CSS is definitely not the correct way. I believe "template includes" are more relevant to you. Commented Feb 24, 2015 at 15:24

1 Answer 1

5

This doesn't work because src has nothing to do with rendering style.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.