Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4060498
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:20:43+00:00 2026-05-20T15:20:43+00:00

Hello all I am trying to work through (learn) MVC3 and I was playing

  • 0

Hello all I am trying to work through (learn) MVC3 and I was playing aroudn with formatting my view using CSS. When using html / webforms have been able to use div tags and apply to that div teh approiate css style.

When using MVC adn creating the layout in my view I have found that multiple CSS styles are not being inheritted.

for example: (sorry for the image but razor syntax seemed to fail on the code cut/paste

enter image description here

In the above I had a div tag for certain sections. however when I used the class property

<div class="myfirststyle" >some content</div>

for each of these div tags only the first one would be detected. The remaining div tags seemed to inherit from the main body style. also defined in the main CSS file.

Can anyone point me to some information on how to setup and style div tags within a view using CSS instead of the stylel property as shown in the above image OR is this correct as you cannot directly call CSS styles from a view as they are only recognized by the page layout.cshtml or masterpage?

Thanks in advance

Update: to help troubleshoot what is happening please refer to the following

Code within the view (using razor engine)
enter image description here

code within the CSS

code within the CSS

output from developer toolbar notice how first div layer attributes are detected
enter image description here

output from developer toolbar notice now how image div does not have a style applied

enter image description here

What is interesting is that when viewing the source in html you can still see the CSS tags within the DIV tags they are just not being picked up or inherited for some reason after the first node/div tag

Thanks again for any pointers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:20:44+00:00Added an answer on May 20, 2026 at 3:20 pm

    Definitely not the case. Something else is going on.

    Did you include your CSS file in the view or it’s master page?

    <link href="@Url.Content("~/Content/YourCSS.css")" rel="stylesheet" type="text/css" />
    

    Or manually add the CSS to your view?

    <style type="text/css">
        div.myfirststyle { ... }
    </style>
    

    If so, have you confirmed the spelling of classes? Typos happen, and we can’t see from your image whether or not you added classes to divs. Add some of your code even if you can’t format it well enough 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn how to include all the files in a directory using
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
I'm trying to work through Apple's CoreData Utility Tutorial . It asks me to
I'm trying to read all class names from HTML element in the following way.
Hello I'm an amateur trying to learn/improve my understanding of Java by writing a
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
All of my codes fail. They should print he, hello and 5 \n 3,
Hello I have test's using unittest. I have a test suite and I am
I'm trying to use async from the asp.net mvc futures, using my own async

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.