Installing hardwood floors can cost between $9 and $12 per square foot, compared with about $3 to $5 per square foot for carpet—so some homeowners opt to install hardwood floors only in some rooms rather than throughout their home. However, carpet typically needs to be replaced if it becomes stained or worn out.