In the View of my project, for the table it is impossible to set the alignment of the headers in the middle, but the values ​​of the columns are:

EditElLearn.cshtml

@using WebApplication1.ViewModels; @model WebApplication1.ViewModels.Monit10ElListVM @{ ViewBag.Title = "EditElLearn"; } ... @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.HiddenFor(x=>x.ElCode) int rowNumber = 0; <table class="table table-striped table-bordered table-condensed" cols="6" border="1" cellspacing="0" cellpadding="10" align="center"> <tr bgcolor="#efefef"> <th align="center"> № п/п </th> <th align="center" width="20%"> Фамилия </th> <th align="center" width="18%"> Имя </th> <th align="center" width="14%"> Отчество </th> <th align="center" width="12%"> Класс </th> <th align="center" width="14%"> % выполнения элемента содержания по КИМ ОГЭ-2015</th> <th align="center" width="14%"> Коррекционная оценка</th> ОГЭ-2015</th> <th width="14%"> Коррекционная оценка</th> </tr> @for (int i = 0; i < Model.Monit10Learnes.Count; i++ ) { rowNumber++; <tr bgcolor="#efefef"> <td align="center"> @Html.DisplayFor(x => rowNumber) </td> <td> @Html.DisplayFor(x => x.Monit10Learnes[i].Surname) </td> <td> @Html.DisplayFor(x => x.Monit10Learnes[i].Name) </td> <td> @Html.DisplayFor(x => x.Monit10Learnes[i].SecondName) </td> <td align="center"> @Html.DisplayFor(x => x.Monit10Learnes[i].ClassName) </td> <td align="center"> @Html.DisplayFor(x => x.Monit10Learnes[i].ValueOge15) </td> <td align="center"> @Html.EditorFor(x => x.Monit10Learnes[i].RatingValue) </td> @Html.HiddenFor(x => x.Monit10Learnes[i].RatingID) </tr> } </table> <div class="form-group"> <div class="col-md-offset-0"> <input type="submit" value="Сохранить" class="btn btn-success" /> </div> </div> } 

enter image description here

With what it can be connected?

    2 answers 2

    Knowledgeable people suggest using CSS:

     text-align: center; 

    Because the use of the align and valign attributes in blocks,, and were excluded in HTML 5. They were excluded in favor of CSS for text alignment. Instead, CSS has text alignments that extend to the inline content of block elements.

    More information can be found here.

    As an option - you can write as follows:

     <th class="not_mapped_style" style="text-align:center">DisplayName</th> 

      In order that any css is more priority than this obsolete attribute. Somewhere there is a css-style doing left-justification. Use css to style the table.

      And generally, stop.
      You are only trying to align the first heading in the middle, and the rest are not.

      • I corrected - now there is an attempt to align all the headers. Still does not help. - Adam
      • one
        @adamshakhabov, I said, this attribute, which we should forget at all, has a lower priority than that of the bootstrap. As far as I remember, you need to write something like .table > tbody > tr > th { text-align: center; } .table > tbody > tr > th { text-align: center; } , and .table better to replace with your class. - Qwertiy